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

[WIP] Native Proxy support for Irssi #148

Closed
wants to merge 15 commits into from
Closed

[WIP] Native Proxy support for Irssi #148

wants to merge 15 commits into from

Conversation

hawken93
Copy link

@hawken93 hawken93 commented Oct 3, 2014

See the changes in TODO. There are warnings produced while running it and there are also some usage of "attribute((packed));"
Nevertheless, I would like feedback :)

ensc and others added 12 commits October 3, 2014 15:06
This patch creates a hook into the net_connect*() methods which call a
method to connect to a proxy.

Previous solution to send certain strings in the normal IRC dialog was
some kind of hack as most proxies require some kind of negotation.

E.g. HTTP proxies sent a 'HTTP/1.0 200 Connection established' HTTP header
and clients have to wait for it.  Else, sent bytes of the following IRC
login will be dropped silently.

With old method, it is also impossible to tunnel SSL IRC connections
through the proxy as proxy speaks plain text or a special protocol while
e.g. 'CONNECT ... HTTP/1.0' will be encrypted with key of IRC server.

There are further enhancements possible: the whole net_connect stuff
should be made asynchronously. Currently, only the hostname is resolved
in the background (which makes little sense of local proxies usually).
This method implements the string + string_after mechanism implemented by
previous irssi versions.

To use, set
* proxy_type to 'simple' or keep it empty
* string + string_after in the known ways
This patch adds code for connecting through HTTP proxies. Open issues are:

* support of proxy authentication
* a possible DOS due to the usage of g_io_channel_read_line_string() which
  does not allow to specify a maximum length of line.

To use this method:
* set 'proxy_type' to 'http'
This patch adds code for connecting through SOCKS5 proxies. It was
primarily written for use with TOR, so there are some open issues:

* it only allows to make proxy requests with full hostnames; ipv4/ipv6 is
  not supported

* GSSAPI authentication (which is mentioned as mandatory in RFC 1928) is
  not implemented

* plaintext authentication is untested

To use it
* set 'proxy_type' to 'socks5'
This patch adds the code and rules to build the various proxy methods.
@hawken93
Copy link
Author

hawken93 commented Oct 3, 2014

Warnings when using socks5:
-!- Irssi: warning settings_get(proxy_username) : not found
-!- Irssi: warning Need to set the channel buffered before setting the encoding.
-!- Irssi: warning Assuming this is what you meant and acting accordingly.
-!- Irssi: error SOCKS5: bound to 0.0.0.0:0
-!- Irssi: warning Need to set the channel buffered before setting the encoding.
-!- Irssi: warning Assuming this is what you meant and acting accordingly.

@hawken93
Copy link
Author

hawken93 commented Oct 3, 2014

01:20 [proxy]
01:20 proxy_type = meh
/connect
irssi exits with this message: Trace/breakpoint trap

{
struct _network_proxy_http *self = container_of(proxy, struct _network_proxy_http, proxy);

g_free((void *)self->password);
Copy link
Member

Choose a reason for hiding this comment

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

Nit: No need to cast here and elsewhere for g_free().

@hawken93
Copy link
Author

hawken93 commented Oct 4, 2014

To avoid producing warnings, I will have to change a few structs to use "char" instead of "const char" as well. Is this what you want? :)

@ailin-nemui
Copy link
Contributor

ailin-nemui commented Oct 4, 2014

Hi,

  • Thanks for getting involved with irssi!
  • Better proxy support would be welcome!
  • I believe it won't be straight forward to merge this branch
  • In my experience you need long breath to resolve a merge
  • Irssi needs someone who not only submits the initial patch but also cares for it in the long run (can fix bug reports etc)
  • Network connections must remain non-blocking
  • SSL must be supported through proxies; should ssl-proxies be supported?
  • container_of must go away
  • inheritance must be modeled as the other irssi objects
  • functions should not start with _ unless they are static functions used for ftable callback
  • The "new" http proxy support is no improvement over the old code
  • HTTP Auth is now even more difficult?!
  • Whether parsing socks with packed structs is permissible
  • Maybe there is another socks library that could be used?
  • Whether DNS etc is done properly through/with the proxy?
    Good luck!

@ahf
Copy link
Member

ahf commented Oct 4, 2014

What Nei said.

@hawken93
Copy link
Author

hawken93 commented Oct 4, 2014

Thanks for the feedback :) I'll see what I can do

@hawken93
Copy link
Author

hawken93 commented Oct 4, 2014

I need some help with the inheritance modeling, I don't know how it works.. :-|
(By this, I mean the ".c : irssi" stuff found in the top of every .c file)

@ahf
Copy link
Member

ahf commented Oct 12, 2014

I'm going to add a few things to Nei's comment.

How about the UI? We shouldn't add new features unless there's a good use-case for the feature. I think there's a very good use-case for supporting multiple proxies, but I think we must ensure that our use-cases are correct.

The three scenarios I see is:

  1. I'm using Irssi at a company that have a firewall that requires me to connect to IRC via some company controlled proxy server. In this case, all my outgoing connections from Irssi must go through the proxy.
  2. I'm using Irssi at home and want to connect to a network where I don't want to reveal my identity, for some reason, and therefore I'd prefer to use something like Tor. In this case, I want to be able to specify that "this server connection should always use Tor.
  3. For some reason, I have to go through a proxy to connect to one of my IRC servers. Again, I'd have to be able to specify a proxy parameter for a single connection. I haven't seen this, ever.

User Interface

Listening available proxy options:

/proxy

Adding a new proxy:

/proxy add -type socks4a -host 127.0.0.1 -port 9050 Tor
/proxy add -type http -host 192.168.1.2 -port 8080 -user businessahf -password yolo BigMoneyIncProxy

Specifying a proxy for a given connection:

/server add -proxy Tor Freenode

Specifying a proxy for all connections:

/set default_proxy Tor

If a given connection have a proxy server that's different than the default_proxy, the default_proxy loses. It should be possible to specify on a server, that no proxy should be used as well.

Discuss!

@ahf
Copy link
Member

ahf commented Oct 12, 2014

Oh, and more importantly: we need to keep in mind that some people using Irssi really should never connect to IRC over anything but Tor, so it's important that if, for example, a user have specified that his default_proxy is Tor, then if the Tor proxy doesn't exist, we shouldn't even try to make the connection, but fail with an error message, as early as possible, informing the user that the proxy connection doesn't exist.

@ahf ahf changed the title Add ensc/irssi's native proxy code into irssi Native Proxy support for Irssi Oct 12, 2014
@dgl
Copy link
Member

dgl commented Jan 26, 2015

Just mentioned on #irssi that it would be cool to have support for external proxies (ala ssh's ProxyCommand). That way we don't need to support every proxy type but people can still experiment. (To be clear this would be in addition to the proxy types here as those seem reasonable to have in core).

@vague666
Copy link
Member

Just an opinion, but -host shouldn't be used to specify server to connect to since it's used to specify the interface to bind to elsewhere in irssi(/server), no need to add to the confusion

@ahf
Copy link
Member

ahf commented Sep 16, 2015

Good point, thanks :-)

@dequis dequis added the WIP label Sep 23, 2015
@ailin-nemui ailin-nemui modified the milestone: 0.8.19 Nov 1, 2015
@ailin-nemui ailin-nemui changed the title Native Proxy support for Irssi [WIP] Native Proxy support for Irssi Dec 14, 2015
@ghost ghost mentioned this pull request Apr 14, 2016
@dequis
Copy link
Member

dequis commented Aug 24, 2016

This lives in https://github.com/irssi/irssi/tree/orphaned/native-proxy now

@ailin-nemui ailin-nemui modified the milestones: 0.8.21, 1.0.1 Jan 3, 2017
@ailin-nemui ailin-nemui mentioned this pull request Aug 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants