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
34fc1d40
Commit
34fc1d40
authored
Oct 31, 2015
by
louiz’
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement a basic webirc support
See
https://kiwiirc.com/docs/webirc
fix
#3135
parent
2c932cf0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
6 deletions
+70
-6
doc/biboumi.1.md
doc/biboumi.1.md
+7
-0
src/bridge/bridge.cpp
src/bridge/bridge.cpp
+5
-3
src/irc/irc_client.cpp
src/irc/irc_client.cpp
+42
-2
src/irc/irc_client.hpp
src/irc/irc_client.hpp
+16
-1
No files found.
doc/biboumi.1.md
View file @
34fc1d40
...
...
@@ -96,6 +96,13 @@ The configuration file uses a simple format of the form
username of each user will be set to the nick they used to connect to the
IRC server.
`webirc_password`
Configure a password to be communicated to the IRC server, as part of the
WEBIRC message (see https://kiwiirc.com/docs/webirc). If this option is
set, an additional DNS resolution of the hostname of each XMPP server will
be made when connecting to an IRC server.
`log_file`
A filename into which logs are written. If none is provided, the logs are
...
...
src/bridge/bridge.cpp
View file @
34fc1d40
...
...
@@ -56,7 +56,8 @@ void Bridge::clean()
while
(
it
!=
this
->
irc_clients
.
end
())
{
IrcClient
*
client
=
it
->
second
.
get
();
if
(
!
client
->
is_connected
()
&&
!
client
->
is_connecting
())
if
(
!
client
->
is_connected
()
&&
!
client
->
is_connecting
()
&&
!
client
->
get_resolver
().
is_resolving
())
it
=
this
->
irc_clients
.
erase
(
it
);
else
++
it
;
...
...
@@ -94,16 +95,17 @@ IrcClient* Bridge::make_irc_client(const std::string& hostname, const std::strin
{
auto
username
=
nickname
;
auto
realname
=
nickname
;
Jid
jid
(
this
->
user_jid
);
if
(
Config
::
get
(
"realname_from_jid"
,
"false"
)
==
"true"
)
{
Jid
jid
(
this
->
user_jid
);
username
=
jid
.
local
;
realname
=
this
->
get_bare_jid
();
}
this
->
irc_clients
.
emplace
(
hostname
,
std
::
make_shared
<
IrcClient
>
(
this
->
poller
,
hostname
,
nickname
,
username
,
realname
,
this
));
realname
,
jid
.
domain
,
this
));
std
::
shared_ptr
<
IrcClient
>
irc
=
this
->
irc_clients
.
at
(
hostname
);
return
irc
.
get
();
}
...
...
src/irc/irc_client.cpp
View file @
34fc1d40
...
...
@@ -26,9 +26,11 @@ using namespace std::chrono_literals;
IrcClient
::
IrcClient
(
std
::
shared_ptr
<
Poller
>
poller
,
const
std
::
string
&
hostname
,
const
std
::
string
&
nickname
,
const
std
::
string
&
username
,
const
std
::
string
&
realname
,
Bridge
*
bridge
)
:
const
std
::
string
&
realname
,
const
std
::
string
&
user_hostname
,
Bridge
*
bridge
)
:
TCPSocketHandler
(
poller
),
hostname
(
hostname
),
user_hostname
(
user_hostname
),
username
(
username
),
realname
(
realname
),
current_nick
(
nickname
),
...
...
@@ -113,6 +115,39 @@ void IrcClient::on_connection_failed(const std::string& reason)
void
IrcClient
::
on_connected
()
{
const
auto
webirc_password
=
Config
::
get
(
"webirc_password"
,
""
);
static
std
::
string
resolved_ip
;
if
(
!
webirc_password
.
empty
())
{
if
(
!
resolved_ip
.
empty
())
this
->
send_webirc_command
(
webirc_password
,
resolved_ip
);
else
{
// Start resolving the hostname of the user, and call
// on_connected again when it’s done
this
->
dns_resolver
.
resolve
(
this
->
user_hostname
,
"5222"
,
[
this
](
const
struct
addrinfo
*
addr
)
{
resolved_ip
=
addr_to_string
(
addr
);
// Only continue the process if we
// didn’t get connected while we were
// resolving
if
(
this
->
is_connected
())
this
->
on_connected
();
},
[
this
](
const
char
*
error_msg
)
{
if
(
this
->
is_connected
())
{
this
->
on_connection_close
(
"Could not resolve hostname "
s
+
this
->
user_hostname
+
": "
+
error_msg
);
this
->
send_quit_command
(
""
);
}
});
return
;
}
}
#ifdef USE_DATABASE
auto
options
=
Database
::
get_irc_server_options
(
this
->
bridge
->
get_bare_jid
(),
this
->
get_hostname
());
...
...
@@ -253,7 +288,7 @@ void IrcClient::send_raw(const std::string& txt)
void
IrcClient
::
send_user_command
(
const
std
::
string
&
username
,
const
std
::
string
&
realname
)
{
this
->
send_message
(
IrcMessage
(
"USER"
,
{
username
,
"ignored"
,
"ignored"
,
realname
}));
this
->
send_message
(
IrcMessage
(
"USER"
,
{
username
,
this
->
user_hostname
,
"ignored"
,
realname
}));
}
void
IrcClient
::
send_nick_command
(
const
std
::
string
&
nick
)
...
...
@@ -266,6 +301,11 @@ void IrcClient::send_pass_command(const std::string& password)
this
->
send_message
(
IrcMessage
(
"PASS"
,
{
password
}));
}
void
IrcClient
::
send_webirc_command
(
const
std
::
string
&
password
,
const
std
::
string
&
user_ip
)
{
this
->
send_message
(
IrcMessage
(
"WEBIRC"
,
{
password
,
"biboumi"
,
this
->
user_hostname
,
user_ip
}));
}
void
IrcClient
::
send_kick_command
(
const
std
::
string
&
chan_name
,
const
std
::
string
&
target
,
const
std
::
string
&
reason
)
{
this
->
send_message
(
IrcMessage
(
"KICK"
,
{
chan_name
,
target
,
reason
}));
...
...
src/irc/irc_client.hpp
View file @
34fc1d40
...
...
@@ -6,6 +6,7 @@
#include <irc/iid.hpp>
#include <network/tcp_socket_handler.hpp>
#include <network/resolver.hpp>
#include <unordered_map>
#include <utility>
...
...
@@ -27,7 +28,8 @@ class IrcClient: public TCPSocketHandler
public:
explicit
IrcClient
(
std
::
shared_ptr
<
Poller
>
poller
,
const
std
::
string
&
hostname
,
const
std
::
string
&
nickname
,
const
std
::
string
&
username
,
const
std
::
string
&
realname
,
Bridge
*
bridge
);
const
std
::
string
&
realname
,
const
std
::
string
&
user_hostname
,
Bridge
*
bridge
);
~
IrcClient
();
/**
* Connect to the IRC server
...
...
@@ -88,6 +90,7 @@ public:
*/
void
send_nick_command
(
const
std
::
string
&
username
);
void
send_pass_command
(
const
std
::
string
&
password
);
void
send_webirc_command
(
const
std
::
string
&
password
,
const
std
::
string
&
user_ip
);
/**
* Send the JOIN irc command.
*/
...
...
@@ -250,11 +253,18 @@ public:
std
::
string
get_nick
()
const
{
return
this
->
current_nick
;
}
bool
is_welcomed
()
const
{
return
this
->
welcomed
;
}
const
Resolver
&
get_resolver
()
const
;
private:
/**
* The hostname of the server we are connected to.
*/
const
std
::
string
hostname
;
/**
* The hostname of the user. This is used in the USER and the WEBIRC
* commands, but only the one in WEBIRC will be used by the IRC server.
*/
const
std
::
string
user_hostname
;
/**
* The username used in the USER irc command
*/
...
...
@@ -330,6 +340,11 @@ private:
* A set of (lowercase) nicknames to which we sent a private message.
*/
std
::
set
<
std
::
string
>
nicks_to_treat_as_private
;
/**
* DNS resolver, used to resolve the hostname of the user if we are using
* the WebIRC protocole.
*/
Resolver
dns_resolver
;
IrcClient
(
const
IrcClient
&
)
=
delete
;
IrcClient
(
IrcClient
&&
)
=
delete
;
...
...
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