Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
451 views
in Q2A Core by
Hello,

I was able to make some changes to dev branch in my forked repo (https://github.com/alakuapark/question2answer) for getting ipv6 working in  q2a.

All ip storing fields in database  where changed to varbinary(16) and read/writes to this fields are made with the following stored procedures:

CREATE FUNCTION `IpToString`(`ip` VARBINARY(16)) RETURNS varchar(39)  BEGIN
IF IS_IPV6(INET6_NTOA(ip)) THEN RETURN INET6_NTOA(ip);  
ELSE    RETURN INET_NTOA(ip);
END IF;
END'

CREATE FUNCTION `StringToIp`(`ip` VARCHAR(39)) RETURNS VARBINARY(16)
BEGIN
DECLARE s VARBINARY(16);
IF IS_IPV6(ip) THEN set s=INET6_ATON(ip);
ELSE set s=INET_ATON(ip);
END IF;
RETURN s;
END;

Changed files:

qa-include/db/admin.php
qa-include/db/blobs.php
qa-include/db/cookies.php
qa-include/db/hotness.php
qa-include/db/install.php
qa-include/db/limits.php
qa-include/db/post-create.php
qa-include/db/post-update.php
qa-include/db/selects.php
qa-include/db/users.php

I would like to discuss about this feature with maintainers before asking a pull request.

Best regards,
Q2A version: 1.7.4 dev
by
Good solution.

1 Answer

+2 votes
by
Thanks for the keen interest in Q2A! IPv6 support has actually already been implemented in Q2A, for the upcoming v1.8.

But it's been a long time in development so v1.7.4 is seeming out of date now. Hoping to get it released soon, but I'm quite busy with paid work recently.
by
Also @alakuapark, just looked at the commits you made, what is the 'StringToIp' function you're using? I don't see that in MySQL.
by
It's my  own stored function  for writing ipv4/ipv6 addresses as varbinary in the database. The code is in my post.
by
Ah OK I see. In the end we used the IPv6 functions that are available in PHP rather than using MySQL. Seemed like the best way for compatibility.

Welcome to the Q&A site for Question2Answer.

If you have a question about Q2A, please ask here, in English.

To report a bug, please create a new issue on Github or ask a question here with the bug tag.

If you just want to try Q2A, please use the demo site.

Categories

...