Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
biboumi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
88
Issues
88
List
Boards
Labels
Service Desk
Milestones
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
louiz’
biboumi
Commits
12c8b1ae
Commit
12c8b1ae
authored
May 15, 2014
by
louiz’
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disconnect the user from all its IRC servers whenever he returns an error
fix
#2524
parent
712b7bdf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
4 deletions
+34
-4
src/bridge/bridge.cpp
src/bridge/bridge.cpp
+1
-2
src/bridge/bridge.hpp
src/bridge/bridge.hpp
+2
-1
src/xmpp/xmpp_component.cpp
src/xmpp/xmpp_component.cpp
+31
-1
No files found.
src/bridge/bridge.cpp
View file @
12c8b1ae
...
...
@@ -41,11 +41,10 @@ static std::tuple<std::string, std::string> get_role_affiliation_from_irc_mode(c
return
std
::
make_tuple
(
"participant"
,
"none"
);
}
void
Bridge
::
shutdown
()
void
Bridge
::
shutdown
(
const
std
::
string
&
exit_message
)
{
for
(
auto
it
=
this
->
irc_clients
.
begin
();
it
!=
this
->
irc_clients
.
end
();
++
it
)
{
const
std
::
string
exit_message
(
"Gateway shutdown"
);
it
->
second
->
send_quit_command
(
exit_message
);
it
->
second
->
leave_dummy_channel
(
exit_message
);
}
...
...
src/bridge/bridge.hpp
View file @
12c8b1ae
...
...
@@ -27,11 +27,12 @@ public:
/**
* QUIT all connected IRC servers.
*/
void
shutdown
();
void
shutdown
(
const
std
::
string
&
exit_message
);
/**
* Remove all inactive IrcClients
*/
void
clean
();
static
Xmpp
::
body
make_xmpp_body
(
const
std
::
string
&
str
);
/***
**
...
...
src/xmpp/xmpp_component.cpp
View file @
12c8b1ae
...
...
@@ -34,6 +34,19 @@ using namespace std::string_literals;
unsigned
long
XmppComponent
::
current_id
=
0
;
static
std
::
set
<
std
::
string
>
kickable_errors
{
"gone"
,
"internal-server-error"
,
"item-not-found"
,
"jid-malformed"
,
"recipient-unavailable"
,
"redirect"
,
"remote-server-not-found"
,
"remote-server-timeout"
,
"service-unavailable"
,
"malformed-error"
};
XmppComponent
::
XmppComponent
(
const
std
::
string
&
hostname
,
const
std
::
string
&
secret
)
:
ever_auth
(
false
),
last_auth
(
false
),
...
...
@@ -128,7 +141,7 @@ void XmppComponent::shutdown()
{
for
(
auto
it
=
this
->
bridges
.
begin
();
it
!=
this
->
bridges
.
end
();
++
it
)
{
it
->
second
->
shutdown
();
it
->
second
->
shutdown
(
"Gateway shutdown"
);
}
}
...
...
@@ -359,6 +372,23 @@ void XmppComponent::handle_message(const Stanza& stanza)
if
(
subject
)
bridge
->
set_channel_topic
(
iid
,
subject
->
get_inner
());
}
else
if
(
type
==
"error"
)
{
const
XmlNode
*
error
=
stanza
.
get_child
(
COMPONENT_NS
":error"
);
// Only a set of errors are considered “fatal”. If we encounter one of
// them, we purge (we disconnect the user from all the IRC servers).
// We consider this to be true, unless the error condition is
// specified and is not in the kickable_errors set
bool
kickable_error
=
true
;
if
(
error
)
{
const
XmlNode
*
condition
=
error
->
get_last_child
();
if
(
kickable_errors
.
find
(
condition
->
get_name
())
==
kickable_errors
.
end
())
kickable_error
=
false
;
}
if
(
kickable_error
)
bridge
->
shutdown
(
"Error from remote client"
);
}
else
{
if
(
body
&&
!
body
->
get_inner
().
empty
())
...
...
Write
Preview
Markdown
is supported
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