zorael / kameloso

IRC bot with Twitch support
Boost Software License 1.0
9 stars 3 forks source link

connect via SSL #103

Closed FraMecca closed 4 years ago

FraMecca commented 4 years ago

is there a way to use this bot in servers that are ssl only? I can't find anything and I get

Connection error: invalid server response! (Connection reset by peer)

whenever I try to connect via port 6697 on a server that is ssl only

zorael commented 4 years ago

Hello!

The short answer is, not currently. I have not had a need for it so I haven't given it any thought.

It's an interesting proposition, however. There's nothing fundamentally stopping it, the connector and listener Fibers will need SSL variants, but once such are in place I imagine it should just work. I just... need to learn how to connect with SSL and read from an SSL socket.

I'll look into it, but it'll take a while, depending on whether or not I find something I can copy and dissect to learn from.

zorael commented 4 years ago

I have something that seems to work, in the ssl branch. I tried it with freenode and Rizon and could connect to, write to and read from both. freenode successfully said "[...] is using a secure connection".

It wasn't a big change but only because I could reuse others' work (https://github.com/ikod/dlang-requests/blob/master/source/requests/ssl_adapter.d).

You need a clone of the ssl branch of upstream lu for the time being.

git clone https://github.com/zorael/lu.git -b ssl
dub add-local lu

If you need to be able to supply a private certificate for your server you may be able to use the SSL_CERT_FILE environment variable. If it's a big deal, I think I can add support for specifying one at the command line and/or in the configuration file instead.

It will detect SSL if the port is 6697, 9999 or some other common SSL port. If your server uses a different port you can manually toggle it with --ssl. Alternatively in the configuration file; just regenerate it first with --writeconfig and the entry should pop up in the core section.

I'm 700 commits into 1.8.2 and was planning to tag a 1.9.0 any day now, at which point I'd sync the three projects (kameloso the bot; dialect the IRC parser; and lu the general library bits). I'll include all this if it seems to work. Then you wouldn't need the extra dub add-local.

Let me know if it works (or doesn't).

FraMecca commented 4 years ago

thank you a lot. I'll try that asap and report back

FraMecca commented 4 years ago

Thanks, it seems to be working. You can close

zorael commented 4 years ago

Thanks!

Merged in 830755a18346424a952d7e17bd6cc8fb2537bc84.