Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unencrypted support connections plus proxy support #32

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Thaodan
Copy link
Contributor

@Thaodan Thaodan commented Sep 25, 2022

@Thaodan Thaodan force-pushed the thaodan/connection_improvements branch 4 times, most recently from 2810565 to f3798c1 Compare September 27, 2022 06:44
@Thaodan
Copy link
Contributor Author

Thaodan commented Sep 27, 2022

Everything works now except that in Bitlbee the select encryption option somehow doesn't work, have to check.

@Thaodan Thaodan force-pushed the thaodan/connection_improvements branch 2 times, most recently from 1010377 to e67378f Compare September 27, 2022 09:36
@Thaodan
Copy link
Contributor Author

Thaodan commented Sep 27, 2022

Works now in Bitlbee too, Bitlbee didn't like the reverse option list.

@EionRobb
Copy link
Owner

Might also want to check that all the tabs didn't turn into spaces before you mark it as ready to merge :)

@EionRobb EionRobb marked this pull request as draft September 27, 2022 09:39
@Thaodan Thaodan force-pushed the thaodan/connection_improvements branch from e67378f to 1dfbaf3 Compare September 27, 2022 10:08
@Thaodan
Copy link
Contributor Author

Thaodan commented Sep 27, 2022

Might also want to check that all the tabs didn't turn into spaces before you mark it as ready to merge :)

Fixing that right now.

Are you open to adding editorconfig to the repo to avoid such issues in the future?

@Thaodan Thaodan changed the title WIP: Unencrypted support connections plus proxy support Unencrypted support connections plus proxy support Sep 27, 2022
@EionRobb
Copy link
Owner

Are you open to adding editorconfig to the repo to avoid such issues in the future?

Sounds good :)

@Thaodan Thaodan force-pushed the thaodan/connection_improvements branch from b240888 to 463b195 Compare September 27, 2022 13:51
@Thaodan Thaodan marked this pull request as ready for review September 27, 2022 16:41
librocketchat.c Outdated Show resolved Hide resolved
librocketchat.c Outdated Show resolved Hide resolved
librocketchat.c Outdated Show resolved Hide resolved


if (ya->websocket_server != ya->server) {
host = g_strdup(ya->websocket_server);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this leak the memory of the old host? Need g_free(host) before assign?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I need to do so? host is just a plain char array without malloc created in the purple function.

librocketchat.c Outdated Show resolved Hide resolved
if (ya->websocket != NULL)
purple_ssl_close(ya->websocket);
else if (ya->fd > 0) {
if (ya->pc->inpa)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is pc->inpa exposed through a function rather than direct struct access? If so can we use that func for forwards compatibility?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Purples Jabber plugin also uses the same way to access pc. The pc is part of the account structure, I'm not sure how that would change with Purple 3.x but I don't see any of that so far.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Purple 3 makes all the eg PurpleConnection and PurpleAccount structs private

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh it seams I should have used ya->inpa instead.
Purple 3.x would do g_source_remove(ya->inpa).

Copy link
Contributor Author

@Thaodan Thaodan Sep 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept that part as Purple 2.x does it the same for Jabber.
The Purple 3.x section would look differently anyway..

The plugin "uses" purple_ssl_connect for Purple 3.x however this has been removed and replaced by Gio.
E.g. see here:
https://keep.imfreedom.org/pidgin/pidgin/file/tip/libpurple/protocols/jabber/jabber.c#l686

I would favor to merge this section as is and the Purple 3.x support should be fixed in another PR (#33).

"connection_security", encryption_values);
account_options = g_list_append(account_options, option);

option = purple_account_option_string_new(N_("Proxy"), "proxy", "");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's proxy options available in the libpurple api that can be used instead from the proxy tab using the PurpleProxyInfo stuff in purple_proxy_get_setup() https://docs.imfreedom.org/pidgin2/proxy_8h.html#a6995e6f63718dcd8644b9d4ef471392a if that makes things easier?

Copy link
Contributor Author

@Thaodan Thaodan Sep 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing is that isn't really a "proxy", it's more like using another host instead of the real host.
It works by using either stunnel or socat as an ssl proxy - both work fine from my tests.

I'm not sure, does using purple_proxy_get_setup() set anything else?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right! This is so you can add in the client cert? Just putting 2 and 2 together now. With a label like "proxy" I wouldn't want anyone to get tripped up with the other Proxy tab.

Naming stuff is hard.

What about "intermediate server"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about "intermediate server"?

Isn't that also a proxy? I think proxy is accurate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right! This is so you can add in the client cert? Just putting 2 and 2 together now. With a label like "proxy" I wouldn't want anyone to get tripped up with the other Proxy tab.

Yes this and the unencrypted connection so there's no SSL twice.

@EionRobb
Copy link
Owner

Awesome stuff!

- Always initialize variables, ping_frame_len was uninitialized in
  some cases.
- Remove redundant else after if websocket closed switch to goto
  try_reconnect section.
- Handle also errno EINPROGRESS and ENOENT
- Indent

Signed-off-by: Björn Bidar <[email protected]>
- Abstract all operations that affect sockets into small wrappers
- Initialize either TLS or proxy connection depending on the setting

Signed-off-by: Björn Bidar <[email protected]>
The option allows the use of a proxy server that is used instead of
the real server. Since the real server is still needed inside `rc_socket_upgrade()`
we still have to keep it for that.

Signed-off-by: Björn Bidar <[email protected]>
g_memdump is deprecated in glib 2.68.0.

Signed-off-by: Björn Bidar <[email protected]>
@Thaodan Thaodan force-pushed the thaodan/connection_improvements branch from df283d9 to b889eb7 Compare September 28, 2022 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants