Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Radio Telescope Control
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Armin Luntzer
Radio Telescope Control
Commits
cdc9b3d4
Commit
cdc9b3d4
authored
6 years ago
by
Armin Luntzer
Browse files
Options
Downloads
Patches
Plain Diff
server net: add text command for MOTD modification
parent
27fb5c93
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/server/include/net.h
+1
-0
1 addition, 0 deletions
src/server/include/net.h
src/server/net.c
+46
-1
46 additions, 1 deletion
src/server/net.c
src/server/proc/proc_pr_message.c
+4
-0
4 additions, 0 deletions
src/server/proc/proc_pr_message.c
with
51 additions
and
1 deletion
src/server/include/net.h
+
1
−
0
View file @
cdc9b3d4
...
@@ -28,6 +28,7 @@ void net_server_iddqd(gpointer ref);
...
@@ -28,6 +28,7 @@ void net_server_iddqd(gpointer ref);
void
net_server_broadcast_message
(
const
gchar
*
msg
,
gpointer
ref
);
void
net_server_broadcast_message
(
const
gchar
*
msg
,
gpointer
ref
);
void
net_server_direct_message
(
const
gchar
*
msg
,
gpointer
ref
);
void
net_server_direct_message
(
const
gchar
*
msg
,
gpointer
ref
);
void
net_server_set_nickname
(
const
gchar
*
nick
,
gpointer
ref
);
void
net_server_set_nickname
(
const
gchar
*
nick
,
gpointer
ref
);
int
net_server_parse_msg
(
const
gchar
*
msg
,
gpointer
ref
);
#endif
/* _SERVER_INCLUDE_NET_H_ */
#endif
/* _SERVER_INCLUDE_NET_H_ */
...
...
This diff is collapsed.
Click to expand it.
src/server/net.c
+
46
−
1
View file @
cdc9b3d4
...
@@ -174,6 +174,25 @@ exit:
...
@@ -174,6 +174,25 @@ exit:
return
G_SOURCE_REMOVE
;
return
G_SOURCE_REMOVE
;
}
}
static
void
net_push_motd_update
(
void
)
{
gchar
*
buf
;
gchar
*
motd
;
motd
=
server_cfg_get_motd
();
if
(
!
motd
)
return
;
buf
=
g_strdup_printf
(
"The MOTD has been updated and now reads: "
"
\n\n
%s
\n\n
"
,
motd
);
net_server_broadcast_message
(
buf
,
NULL
);
g_free
(
buf
);
g_free
(
motd
);
}
/**
/**
* @brief distribute a list of users to all clients
* @brief distribute a list of users to all clients
...
@@ -205,7 +224,6 @@ static gboolean net_push_userlist_cb(gpointer data)
...
@@ -205,7 +224,6 @@ static gboolean net_push_userlist_cb(gpointer data)
tmp
=
msg
;
tmp
=
msg
;
g_message
(
"%s priv is %d"
,
c
->
nick
,
c
->
priv
);
switch
(
c
->
priv
)
{
switch
(
c
->
priv
)
{
case
PRIV_FULL
:
case
PRIV_FULL
:
buf
=
g_strdup_printf
(
"<tt><span foreground='#FF0000'>"
buf
=
g_strdup_printf
(
"<tt><span foreground='#FF0000'>"
...
@@ -1034,6 +1052,33 @@ void net_server_set_nickname(const gchar *nick, gpointer ref)
...
@@ -1034,6 +1052,33 @@ void net_server_set_nickname(const gchar *nick, gpointer ref)
int
net_server_parse_msg
(
const
gchar
*
msg
,
gpointer
ref
)
{
struct
con_data
*
c
;
c
=
(
struct
con_data
*
)
ref
;
/* ignore if not fully priviledged */
if
(
c
->
priv
<
PRIV_FULL
)
return
-
1
;
/* shorter than our only supported command word */
if
(
strlen
(
msg
)
<
5
)
return
-
1
;
if
(
strncmp
(
msg
,
"!motd"
,
5
))
return
-
1
;
/* stupidly set the motd */
server_cfg_set_motd
(
&
msg
[
5
]);
net_push_motd_update
();
return
0
;
}
/**
/**
* @brief broadcast a text message to all clients
* @brief broadcast a text message to all clients
*/
*/
...
...
This diff is collapsed.
Click to expand it.
src/server/proc/proc_pr_message.c
+
4
−
0
View file @
cdc9b3d4
...
@@ -35,5 +35,9 @@ void proc_pr_message(struct packet *pkt, gpointer ref)
...
@@ -35,5 +35,9 @@ void proc_pr_message(struct packet *pkt, gpointer ref)
if
(
strlen
((
gchar
*
)
c
->
message
)
!=
c
->
len
)
if
(
strlen
((
gchar
*
)
c
->
message
)
!=
c
->
len
)
return
;
return
;
/* see if it is an interpretable command */
if
(
!
net_server_parse_msg
((
const
gchar
*
)
c
->
message
,
ref
))
return
;
net_server_broadcast_message
((
const
gchar
*
)
c
->
message
,
ref
);
net_server_broadcast_message
((
const
gchar
*
)
c
->
message
,
ref
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment