Ticket #1969 (closed enhancement: fixed)

Opened 4 years ago

Last modified 8 months ago

ipv6 support

Reported by: Laurent Bigonville <l.bigonville@…> Owned by: asterix
Priority: normal Milestone:
Component: None Version:
Severity: normal Keywords:
Cc: md@…, ressu@…, phil@…, didier@…, berni@…, stefan@… Blocked By:
OS: All Blocking:

Description

Hi,

adding ipv6 support would be great :)

Attachments

gajim-ipv6-filetransfer.diff.asc (3.6 KB) - added by steelman # poczta ' fm 4 years ago.
enable IPv6 filetransfers
gajim-ipv6-20060727.patch (6.1 KB) - added by didier@… 4 years ago.
Add IPv6 support for transport (not for proxy)
gajim-ipv6.patch (2.4 KB) - added by sgala@… 4 years ago.
patch to get ipv4/ipv6 transport
gajim-ipv6.2.patch (2.1 KB) - added by sgala 3 years ago.
new version, slightly changed to address small error in patch
ipv6.patch (15.8 KB) - added by sgala 3 years ago.
all my ipv6 (or protocol) related patches, current as of now
diverse-connection.patch (12.8 KB) - added by sgala 2 years ago.
Current version of ipv6 patch

Change History

Changed 4 years ago by misc@…

as far as i know, python already support ipv6 by default, can you give

more information about what is missing, and how you tested it ?

Changed 4 years ago by Laurent Bigonville <l.bigonville@…>

Yes python has ipv6 support.

But application must be modified.

You create socket with AF_INET and the resolver doesn't query fo ipv6 adresses.

There is an example in the documentation to have dual-stack application  http://docs.python.org/lib/socket-example.html

Changed 4 years ago by anonymous

  • cc md@… added

Changed 4 years ago by stlman # poczta.fm

IPv6 would be especially useful for file transfers. While c2s

communication does not suffer from NAT at all, it is hell to set up everything for file transfers.

Changed 4 years ago by stlman # poczta ' fm

gajim-ipv6-filetransfer enables (I hope) filetransfers via ipv6. I haven't

tested if it really works but it doesn't break filetransfers with psi via ipv4.

For now it can work only under linux but there are slots for other systems. I don't know how to obtain a list of available IPv6 addresses under any other OS.

There is no support for client to server ipv6 connections because NATs work well enough for c2s TCP connections.

Changed 4 years ago by steelman # poczta ' fm

enable IPv6 filetransfers

Changed 4 years ago by ressu@…

c2s connections would benefit from IPv6 too. For me the jabber server i

connect to is located in the same subnet as my client. The subnet is behind a nat. Currently i use a set of SRV records to get the client to connect to the local address. If the client had IPv6 c2s the first SVR record would be correct and everything would work without all the trickery.

Changed 4 years ago by didier@…

Add IPv6 support for transport (not for proxy)

Changed 4 years ago by phil@…

The IPv6 patch worked just fine, thank you.

Changed 4 years ago by ressu@…

I can also confirm both patches as working. I'm one happy IPv6 camper ;)

Changed 4 years ago by sgala@…

I am testing a patch to support ipv6 without breaking ipv4.

I attach it, it seems to work here.

Missing: more testing and the proxy stuff, which I'll take care of if all goes well.

Changed 4 years ago by anonymous

I get this from the tracker every time I try to insert the patch:

Python Traceback

Traceback (most recent call last):

File "/usr/lib/python2.3/site-packages/trac/web/main.py", line 316, in

dispatch_request

dispatcher.dispatch(req)

File "/usr/lib/python2.3/site-packages/trac/web/main.py", line 201, in

dispatch

resp = chosen_handler.process_request(req)

File "/usr/lib/python2.3/site-packages/trac/attachment.py", line 343, in

process_request

self._do_save(req, attachment)

File "/usr/lib/python2.3/site-packages/trac/attachment.py", line 456, in

_do_save

for field, message in manipulator.validate_attachment(req,

attachment):

File "build/bdist.linux-i686/egg/tracspamfilter/adapters.py", line 102,

in validate_attachment

File "build/bdist.linux-i686/egg/tracspamfilter/api.py", line 70, in

test

File "build/bdist.linux-i686/egg/tracspamfilter/filters/akismet.py",

line 64, in test

File "build/bdist.linux-i686/egg/tracspamfilter/filters/akismet.py",

line 95, in _check_comment UnicodeDecodeError?: 'ascii' codec can't decode byte 0xc3 in position 152: ordinal not in range(128)

Changed 4 years ago by sgala@…

patch to get ipv4/ipv6 transport

Changed 4 years ago by didier__AT__barvaux__DOT__org

I did not try the gajim-ipv6.patch from sgala@…, but it seems to

be wrong. The socket::connect() function is called twice for the self._sock socket.

First one is added by the patch at line 113 in function NonBlockingTcp::connect(). The second one is at line 299 in function NonBlockingTcp::_do_connect(). NonBlockingTcp::_do_connect() is called at the end of NonBlockingTcp::connect(), so there is a problem.

The patch I supplied one month ago (gajim-ipv6-20060727.patch) has not this problem. I successfully tested it with:

  • an IPv4-only ejabberd server,
  • an IPv4/IPv6 ejabberd server,
  • an IPv6-only ejabberd server.

Changed 3 years ago by asterix

trying the first patch result in a TB here when I try to send a file (ipv6 is not supported on my machine, kernel not compiled with it):

[...]

File "/home/asterix/gajim/src/common/connection_handlers.py", line 525, in _siResultCB

self.send_socks5_info(file_props, fast = True)

File "/home/asterix/gajim/src/common/connection_handlers.py", line 181, in send_socks5_info

sha_str, self._result_socks5_sid, file_propssid?)

File "/home/asterix/gajim/src/common/socks5.py", line 85, in start_listener

self.listener.bind()

File "/home/asterix/gajim/src/common/socks5.py", line 813, in bind

self._serv = socket.socket(family, socket.SOCK_STREAM)

File "/usr/lib/python2.4/socket.py", line 148, in init

_sock = _realsocket(family, type, proto)

socket.error: (97, 'Address family not supported by protocol')

one solution could be to put the socket.socket() call in a try/except to catch the exception and fall back to IPV4, is it ok to do that ?

Changed 3 years ago by sgala@…

The approach you are trying is wrong. The right approach to ipv6/ipv4 development, as illustrated in U Drepper introduction (  http://people.redhat.com/drepper/userapi-ipv6.html ) is to use getaddrinfo for the connection parameters.

This works irrespective of ipv4/v6 configuration.

The patch I posted has, as didier pointed, a small problem, but the design is much cleaner and using the right technique. I can't send right now the updated version, as I don't have handy the hard disk of my "deceased" old laptop, but will do so soon.

Changed 3 years ago by sgala

new version, slightly changed to address small error in patch

Changed 3 years ago by sgala

I'm still trying to understand file transfer. SOCKS protocol does not make sense at all with ipv6, where everybody will have globally routable addresses by default. So I guess the socks stuff should be left ipv4 only, and use the public ipv6 for file transfer. ANy clue?

Changed 3 years ago by asterix

yes ! thanks for the patch, could some ppl try it before I commit it for 0.11 ?

Changed 3 years ago by asterix

(In [d6987082a9e307a0085a1b7f6a305154bbe060fb]) [sgala] IPV6 support for connection fith server. see #1969

Changed 3 years ago by asterix

sgala, could you do the same for filetransfert ? the first patch does that, but not with socket.getaddrinfo()

Changed 3 years ago by shtrom-gajim@…

It would be nice if Gajim could fall back on IPv4 when the IPv6 host does not seem to have a listenning Jabberd (instead of giving an error in the case of a dual stack server only listening on IPv4).

Changed 3 years ago by shtrom-gajim@…

The above problem seems to be in common/xmpp/transports_nb.py, in the connect() method lines 109 and below:

for ai in socket.getaddrinfo(server[0],server[1],socket.AF_UNSPEC,socket.SOCK_STREAM):

try:

self._sock=socket.socket(*ai[:3]) self._sock.setblocking(False) self._server=ai[4] break

except:

(...)

It is following the same scheme as in transports.py, but instead of connecting straight away, it justs sets some values, which, even if no IPv6 service exist on the server, will not raise any exception. The first address obtained via getaddrinfo will then always be used, and the connection will fail afterwards, in the _do_connect() method.

Maybe instead of the default on_connect_failure() method, a specific one should be added which will try to connect to the next address resolved for the host and, finally, call the usual on_connect_failure() only if nothing worked. Moreover, in case the connection is correctly established, it might be advisable to set back the normal on_connect_failure() method.

Just a guess, but I hope it helps (:

Changed 3 years ago by junglecow

shtrom-gajim@… wrote:

Maybe instead of the default on_connect_failure() method, a specific one should be added which will try to connect to the next address resolved

Let's not add more twistedness to xmpppy. Gajim already tries to connect to all hosts from SRV lookup, so this code should be integrated with it.

BTW, sgala, I have a question about this patch: in the try…catch block, you test for EINPROGRESS, but which call could cause this exception? And since _server is set last, doesn't this mean that _server can have the wrong value when we get EINPROGRESS?

Changed 3 years ago by anonymous

  • cc berni@… added

Changed 3 years ago by Laurent Bigonville <l.bigonville@…>

Is someone still working on this?

Changed 3 years ago by sgala@…

Laurent: It seems to be "good enogh", I am using it routinely. The file transfer is still missing because I can't understand its logics (if any :P) so I can't patch it.

Other thing missing is to use some thread for the getaddrinfo so that it does not block there, and restore "pure" non-blockedness to gajim. Currently each call to getaddrinfo is a potential blocking point. Again, I'm not confident enough with python to try this in a clean way.

Changed 3 years ago by sgala

all my ipv6 (or protocol) related patches, current as of now

Changed 3 years ago by anonymous

  • cc stefan@… added

Changed 3 years ago by asterix

(In [0f96ca2ecbc436f0d5fa52b74924882264558f2f]) [Santiago Gala] IPv6 filetransfert. see #1969

Changed 2 years ago by Laurent Bigonville

  • os set to All

And what about the failback if the ipv6 connection is not possible?

Changed 2 years ago by asterix

it's in #2958

Changed 2 years ago by sgala

Current version of ipv6 patch

Changed 18 months ago by polymorphm@…

будут ли (или уже существуют?) эти изменения в главном-потоке (не в качестве патчий) ?

whether (or already exist?), these changes in the main-stream (not as a patch)?

Changed 18 months ago by asterix

everything is in trunk, except the nslookup part, which doesn't work yet

Changed 16 months ago by steve-e

Can this bug be closed, when the bosh branch is merged back to trunk?

Changed 9 months ago by johnny

  • status changed from new to needinfo

what is up with this now?

Changed 8 months ago by polymorphm

what is up with this now?

appears on all my tests .. now - direct transfer does not work at all (as ipv6, and ipv4) ..

tried different situations (releases, but not svn) - error is always the same.

[ судя по всем моим тестам.. сейчас -- прямая (direct) передача не работает вообще (как ipv6, так и ipv4).. :-(

пробовал разные ситуации (релизы, но не svn) -- ошибка всегда одна и та же. ]

ipv6:

<!-- Out -->
<iq to="gitsy@no-icq.org/Gajim" type="set" id="IDTO1JQ2WC3KFPLH">
<si xmlns="http://jabber.org/protocol/si" profile="http://jabber.org/protocol/si/profile/file-transfer" id="IDTO1JQ2WC3KFPLH">
<file xmlns="http://jabber.org/protocol/si/profile/file-transfer" name="Ярлык для Far.lnk" size="632">
<desc />
<range />
</file>
<feature xmlns="http://jabber.org/protocol/feature-neg">
<x xmlns="jabber:x:data" type="form">
<field var="stream-method" type="list-single">
<option>
<value>http://jabber.org/protocol/bytestreams</value>
</option>
</field>
</x>
</feature>
</si>
</iq>

<!-- In -->
<iq from='gitsy@no-icq.org/Gajim' to='test.5.4.41@headcounter.org/Gajim' xml:lang='ru' type='result' id='IDTO1JQ2WC3KFPLH'>
<si xmlns='http://jabber.org/protocol/si'>
<feature xmlns='http://jabber.org/protocol/feature-neg'>
<x xmlns='jabber:x:data' type='submit'>
<field var='stream-method'>
<value>http://jabber.org/protocol/bytestreams</value>
</field>
</x>
</feature>
</si>
</iq>

<!-- Out -->
<iq to="gitsy@no-icq.org/Gajim" type="set" id="id_IDTO1JQ2WC3KFPLH">
<query xmlns="http://jabber.org/protocol/bytestreams" mode="tcp" sid="IDTO1JQ2WC3KFPLH">
<streamhost host="2001:0:d5c7:a2d6:0:fbf3:b074:33bf" jid="test.5.4.41@headcounter.org/Gajim" port="28011" />
</query>
</iq>


<!-- In -->
<iq from='gitsy@no-icq.org/Gajim' to='test.5.4.41@headcounter.org/Gajim' xml:lang='ru' type='error' id='id_IDTO1JQ2WC3KFPLH'>
<error code='404'>Could not connect to given hosts</error>
</iq>


ipv4 in one local network:

<iq from='test.5.4.41@headcounter.org/Gajim' to='polymorphm@headcounter.org/Gajim' xml:lang='ru' type='set' id='M4RQ0OWX68VJHEUG'>
<si xmlns='http://jabber.org/protocol/si' profile='http://jabber.org/protocol/si/profile/file-transfer' id='M4RQ0OWX68VJHEUG'>
<file xmlns='http://jabber.org/protocol/si/profile/file-transfer' name='Ярлык для Far.lnk' size='632'>
<desc/>
<range/>
</file>
<feature xmlns='http://jabber.org/protocol/feature-neg'>
<x xmlns='jabber:x:data' type='form'>
<field var='stream-method' type='list-single'>
<option>
<value>http://jabber.org/protocol/bytestreams</value>
</option>
</field>
</x>
</feature>
</si>
</iq>

<iq to="test.5.4.41@headcounter.org/Gajim" type="result" id="M4RQ0OWX68VJHEUG">
<si xmlns="http://jabber.org/protocol/si">
<feature xmlns="http://jabber.org/protocol/feature-neg">
<x xmlns="jabber:x:data" type="submit">
<field var="stream-method">
<value>http://jabber.org/protocol/bytestreams</value>
</field>
</x>
</feature>
</si>
</iq>

<iq from='test.5.4.41@headcounter.org/Gajim' to='polymorphm@headcounter.org/Gajim' xml:lang='ru' type='set' id='id_M4RQ0OWX68VJHEUG'>
<query xmlns='http://jabber.org/protocol/bytestreams' mode='tcp' sid='M4RQ0OWX68VJHEUG'>
<streamhost host='192.168.0.195' jid='test.5.4.41@headcounter.org/Gajim' port='28011'/>
</query>
</iq>

<iq to="test.5.4.41@headcounter.org/Gajim" type="error" id="id_M4RQ0OWX68VJHEUG">
<error code="404">Could not connect to given hosts</error>
</iq>


Changed 8 months ago by Yann Leboulanger <asterix@…>

(In [ac31cbdfda8517e22971055cd70690dd32f29eb8]) when sending file, try to bind ipv6 first. see #1969

Changed 8 months ago by asterix

  • status changed from needinfo to closed
  • resolution set to fixed

you must have a firewall blocking port 28011. it's just not possible that you cannot connect on 192.168.0.195:28011 on local network.

now for ipv6, indeed I did some tests here, and even if I have an ipv6, it bind ipv4 first. I changed that locally, and now ipv6 file transfer work.

Changed 8 months ago by polymorphm

you must have a firewall blocking port 28011. it's just not possible that you cannot connect on 192.168.0.195:28011 on local network.

apologize (one of my computers worked properly). ipv4 works well

---

transfer over ipv6 - works well in svn(hg)-version. [as I understand] problem with ipv6-File-Transfers - in the release of gajim-0.12.1 (built in ubuntu 9.04)

Changed 8 months ago by Yann Leboulanger <asterix@…>

(In [8e8c571c93a3dcd638972b08c3a3e551137bd726]) when sending file, try to bind ipv6 first. see #1969

Add/Change #1969 (ipv6 support)

Author


E-mail address and user name can be saved in the Preferences.


Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
Next status will be 'needinfo'
 
Note: See TracTickets for help on using tickets.