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
5d801ddc
Commit
5d801ddc
authored
Jan 22, 2017
by
louiz’
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a linger_time configuration option on IRC servers
parent
dd129366
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
1 deletion
+43
-1
database/database.xml
database/database.xml
+1
-0
src/bridge/bridge.cpp
src/bridge/bridge.cpp
+21
-1
src/bridge/bridge.hpp
src/bridge/bridge.hpp
+5
-0
src/xmpp/biboumi_adhoc_commands.cpp
src/xmpp/biboumi_adhoc_commands.cpp
+15
-0
tests/end_to_end/__main__.py
tests/end_to_end/__main__.py
+1
-0
No files found.
database/database.xml
View file @
5d801ddc
...
...
@@ -24,6 +24,7 @@
<field
name=
"realname"
type=
"string"
length=
"1024"
default=
""
/>
<field
name=
"verifyCert"
type=
"boolean"
default=
"true"
/>
<field
name=
"trustedFingerprint"
type=
"string"
/>
<field
name=
"lingerTime"
type=
"integer"
default=
"0"
/>
<field
name=
"encodingOut"
type=
"string"
default=
"ISO-8859-1"
/>
<field
name=
"encodingIn"
type=
"string"
default=
"ISO-8859-1"
/>
...
...
src/bridge/bridge.cpp
View file @
5d801ddc
...
...
@@ -11,6 +11,7 @@
#include <database/database.hpp>
#include "result_set_management.hpp"
#include <algorithm>
#include <utils/timed_events.hpp>
using
namespace
std
::
string_literals
;
...
...
@@ -865,7 +866,7 @@ void Bridge::send_muc_leave(Iid&& iid, std::string&& nick, const std::string& me
this
->
user_jid
+
"/"
+
res
,
self
);
IrcClient
*
irc
=
this
->
find_irc_client
(
iid
.
get_server
());
if
(
irc
&&
irc
->
number_of_joined_channels
()
==
0
)
irc
->
send_quit_command
(
""
);
this
->
quit_or_start_linger_timer
(
iid
.
get_server
()
);
}
void
Bridge
::
send_nick_change
(
Iid
&&
iid
,
...
...
@@ -1212,3 +1213,22 @@ void Bridge::set_record_history(const bool val)
this
->
record_history
=
val
;
}
#endif
void
Bridge
::
quit_or_start_linger_timer
(
const
std
::
string
&
irc_hostname
)
{
#ifdef USE_DATABASE
auto
options
=
Database
::
get_irc_server_options
(
this
->
get_bare_jid
(),
irc_hostname
);
const
auto
timeout
=
std
::
chrono
::
seconds
(
options
.
lingerTime
.
value
());
#else
const
auto
timeout
=
0s
;
#endif
const
auto
event_name
=
"IRCLINGER:"
+
irc_hostname
+
".."
+
this
->
get_bare_jid
();
TimedEvent
event
(
std
::
chrono
::
steady_clock
::
now
()
+
timeout
,
[
this
,
irc_hostname
]()
{
IrcClient
*
irc
=
this
->
find_irc_client
(
irc_hostname
);
if
(
irc
)
irc
->
send_quit_command
(
""
);
},
event_name
);
TimedEventsManager
::
instance
().
add_event
(
std
::
move
(
event
));
}
src/bridge/bridge.hpp
View file @
5d801ddc
...
...
@@ -236,6 +236,11 @@ public:
#ifdef USE_DATABASE
void
set_record_history
(
const
bool
val
);
#endif
/**
* Start a timer that will send a QUIT command after the
* configured linger time is expired.
*/
void
quit_or_start_linger_timer
(
const
std
::
string
&
irc_hostname
);
private:
/**
...
...
src/xmpp/biboumi_adhoc_commands.cpp
View file @
5d801ddc
...
...
@@ -329,6 +329,17 @@ void ConfigureIrcServerStep1(XmppComponent&, AdhocSession& session, XmlNode& com
encoding_in_value
.
set_inner
(
options
.
encodingIn
.
value
());
}
encoding_in
.
add_child
(
required
);
XmlSubNode
linger_time
(
x
,
"field"
);
linger_time
[
"var"
]
=
"linger_time"
;
linger_time
[
"type"
]
=
"text-single"
;
linger_time
[
"desc"
]
=
"The number of seconds to wait before sending a QUIT command, after the last channel on that server has been left."
;
linger_time
[
"label"
]
=
"Linger time"
;
{
XmlSubNode
linger_time_value
(
linger_time
,
"value"
);
linger_time_value
.
set_inner
(
std
::
to_string
(
options
.
lingerTime
.
value
()));
}
encoding_in
.
add_child
(
required
);
}
void
ConfigureIrcServerStep2
(
XmppComponent
&
,
AdhocSession
&
session
,
XmlNode
&
command_node
)
...
...
@@ -408,6 +419,10 @@ void ConfigureIrcServerStep2(XmppComponent&, AdhocSession& session, XmlNode& com
value
&&
!
value
->
get_inner
().
empty
())
options
.
encodingIn
=
value
->
get_inner
();
else
if
(
field
->
get_tag
(
"var"
)
==
"linger_time"
&&
value
&&
!
value
->
get_inner
().
empty
())
options
.
lingerTime
=
value
->
get_inner
();
}
options
.
update
();
...
...
tests/end_to_end/__main__.py
View file @
5d801ddc
...
...
@@ -1939,6 +1939,7 @@ if __name__ == '__main__':
"/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='realname']/dataform:value[text()='realname']"
,
"/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='encoding_in']/dataform:value[text()='latin-1']"
,
"/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='encoding_out']/dataform:value[text()='UTF-8']"
,
"/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-single'][@var='linger_time']/dataform:value[text()='0']"
,
"/iq/commands:command/commands:actions/commands:next"
,
),
after
=
partial
(
save_value
,
"sessionid"
,
partial
(
extract_attribute
,
"/iq[@type='result']/commands:command[@node='configure']"
,
"sessionid"
))
...
...
louiz’
@louiz
mentioned in commit
5ef674c4
·
Apr 20, 2017
mentioned in commit
5ef674c4
mentioned in commit 5ef674c4862f1ad265e76ea6fabc20e180871243
Toggle commit list
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