News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

[Outdated] IPv6 support

Started by SleePy, June 29, 2011, 03:25:36 PM

Previous topic - Next topic

vivien

Is this mod compatible with SMF 2.0.14 and PHP 7?

https://custom.simplemachines.org/mods/index.php?mod=3051 say compatible with SMF 2.0 and SMF 2.0.2

d3vcho

Yes, it should be compatible with 2.0.14 as well. You'd need to emulate your forum's version to install it; How can I install a mod that doesn't work in my SMF version?
"Greeting Death as an old friend, they departed this life as equals"

SleePy

It should be noted this mod is not compatible with SMF 2.1's IPv6 support and all IPv6s will be lost during the upgrade.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

MPHV

The banning does not seem to work correctly. I saw other people also had this problem
When I add a new IPv4 ban I get the error: "The database value you're trying to insert does not exist: ip_low5"

Did someone manage to fix this?
Also existing IPv4 ban triggers are not shown in the ban trigger list.
They do seem to work, however i can't manage them.

Has anyone solved this?

vivien

This is problematic because some hosts no longer offer an option to disable IPv6.

I think that like for PHP 7, it should ensure compatibility for SMF 2.0 without waiting for SMF 2.1.

butchs

I block ipv6 with Forum Firewall and bad Behavior which both support ipv6 internally.
I have been truly inspired by the SUGGESTIONS as I sit on my throne and contemplate the wisdom imposed upon me.

Fisch.666

Quote from: vivien on August 20, 2017, 02:55:28 AMIs this mod compatible with SMF 2.0.14 and PHP 7?

I have it installed now on a SMF 2.0.15 running PHP 7.0.x and it seems its working for me (havn't tested it fully).

The only thing i have seen is that the following two errors are logged within the SMF Error Log during the  installation (posted previously in https://www.simplemachines.org/community/index.php?topic=440357.msg3904446#msg3904446):

Quote
2: mysqli_fetch_assoc(): Couldn't fetch mysqli_result
File: /var/www/forum/Packages/temp/database_install.php
Line: 64


2: Missing argument 3 for smf_db_change_column(), called in /var/www/forum/Packages/temp/database_install.php on line 49 and defined
File: /var/www/forum/Sources/DbPackages-mysql.php
Line: 285

Maybe this DB setup message could explain the missing database value here?:


Quote from: MPHV on February 16, 2018, 04:07:36 PM
The banning does not seem to work correctly. I saw other people also had this problem
When I add a new IPv4 ban I get the error: "The database value you're trying to insert does not exist: ip_low5"

Did someone manage to fix this?
Also existing IPv4 ban triggers are not shown in the ban trigger list.
They do seem to work, however i can't manage them.

Has anyone solved this?

rho_simafo

#67
When I tried to install this mode under SMF 2.0.15 it was not successfull.

The message I got:
Too few arguments to function smf_db_change_column(), 2 passed in /htdocs/smfforum.de/Packages/temp/database_install.php on line 49 and at least 3 expected

Mr. Jinx

This mod hasn't been updated for a looooooooong time, and contains some serious flaws. I would not recommend installing it.
If you need IPv6 support badly then you should be looking for other forum software. SMF is just not build for that.

alexetgus

#69
This mod is obsolete. It is no longer compatible with the latest versions of PHP, SQL SGBD and SMF.
It's dammageable...

Packages/temp/database_install.php on line 49 and at least 3 expected

Warlock666

Hi @all,

I got the same error like rho_simafo and reported this at github.

What options are there to run SMF 2.0.15 on an IPv6 enabled Webserver ?

Right now I'm getting this error:

Incorrect string value: '''' for function inet_aton
File: /var/www/forum/Sources/Subs.php
Line: 2667

vbgamer45

Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

wintstar

Quote from: vbgamer45 on October 21, 2019, 03:37:38 PM
Try the mod https://custom.simplemachines.org/mods/index.php?mod=3051 or upgrade to SMF 2.1

@vbgamer45, this does not fix the above reported errors. This mod you linked causes the error message.

Quote from: vivien on March 31, 2018, 11:24:40 AM
This is problematic because some hosts no longer offer an option to disable IPv6.

I think that like for PHP 7, it should ensure compatibility for SMF 2.0 without waiting for SMF 2.1.

Since it still takes some time until SMF 2.1 is released, there should be a patch for SMF 2.0.17.


Quote from: Illori on January 27, 2020, 07:27:21 AM
SMF 2.0 is still feature locked. we are not changing our minds on that.

This really needs to be reconsidered. Because it could become a security issue in 2.0.17. Each IPV6 address is recorded with 0.0.0.0.
Regards Stephan

,,In order for the possible to come into being, the impossible must be attempted again and again."
Hermann Hesse (1877-1962)

My HomepageMy Board - My Atelier

Kindred

that is not the definition of a security issue...
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

wintstar

Bugs in database_install.php

find (https://www.simplemachines.org/community/index.php?topic=440357.msg3904442#msg3904442)
// Fields to add
replace with
db_extend('packages');

// Fields to add


find
// Do the loopy, loop, loe.
foreach ($changed_fields as $column_name => $column_attributes)
$smcFunc['db_change_column']($db_prefix . 'ban_items', $column_attributes);

replace with
// Do the loopy, loop, loe.
foreach ($changed_fields as $column_name => $column_attributes)
if (!in_array($column_name, $table_columns))
$smcFunc['db_change_column']($db_prefix . 'ban_items', $column_attributes);


find
while ($row = $smcFunc['db_fetch_assoc']($request))
replace with
while ($row = $smcFunc['db_fetch_assoc']($result))


There's another bug here  => $smcFunc['db_change_column']. The columns are not changed in the database table.  ::)  Maybe someone has a solution for that.
Regards Stephan

,,In order for the possible to come into being, the impossible must be attempted again and again."
Hermann Hesse (1877-1962)

My HomepageMy Board - My Atelier

Chomper

My Hoster switched to IP6 and so I forced to install this mod, too.

On my smf installation I still get many database errors in log_online table.

So I look at the code and changed INET_ATON() / INET_NTOR() to INET6_ATON() / INET6_NTOA() to support IPv6.

I also changed the datatype from the column "ip" in "log_online" table from int to varbinary16 to store the correct data.

subs.php

find:
$smcFunc['db_query']('', '
UPDATE {db_prefix}log_online
SET log_time = {int:log_time}, ip = IFNULL(INET_ATON({string:ip}), 0), url = {string:url}
WHERE session = {string:session}',
array(
'log_time' => time(),
'ip' => $user_info['ip'],
'url' => $serialized,
'session' => $session_id,
)
);


replace:

$smcFunc['db_query']('', '
UPDATE {db_prefix}log_online
SET log_time = {int:log_time}, ip = IFNULL(INET6_ATON({string:ip}), 0), url = {string:url}
WHERE session = {string:session}',
array(
'log_time' => time(),
'ip' => $user_info['ip'],
'url' => $serialized,
'session' => $session_id,
)
);


find:


$smcFunc['db_insert']($do_delete ? 'ignore' : 'replace',
'{db_prefix}log_online',
array('session' => 'string', 'id_member' => 'int', 'id_spider' => 'int', 'log_time' => 'int', 'ip' => 'raw', 'url' => 'string'),
array($session_id, $user_info['id'], empty($_SESSION['id_robot']) ? 0 : $_SESSION['id_robot'], time(), 'IFNULL(INET_ATON(\'' . $user_info['ip'] . '\'), 0)', $serialized),
array('session')
);


replace:

$smcFunc['db_insert']($do_delete ? 'ignore' : 'replace',
'{db_prefix}log_online',
array('session' => 'string', 'id_member' => 'int', 'id_spider' => 'int', 'log_time' => 'int', 'ip' => 'raw', 'url' => 'string'),
array($session_id, $user_info['id'], empty($_SESSION['id_robot']) ? 0 : $_SESSION['id_robot'], time(), 'IFNULL(INET6_ATON(\'' . $user_info['ip'] . '\'), 0)', $serialized),
array('session')
);


who.php

find:


$request = $smcFunc['db_query']('', '
SELECT
lo.log_time, lo.id_member, lo.url, INET_NTOA(lo.ip) AS ip, mem.real_name,
lo.session, mg.online_color, IFNULL(mem.show_online, 1) AS show_online,
lo.id_spider
FROM {db_prefix}log_online AS lo
LEFT JOIN {db_prefix}members AS mem ON (lo.id_member = mem.id_member)
LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = CASE WHEN mem.id_group = {int:regular_member} THEN mem.id_post_group ELSE mem.id_group END)' . (!empty($conditions) ? '
WHERE ' . implode(' AND ', $conditions) : '') . '
ORDER BY {raw:sort_method} {raw:sort_direction}
LIMIT {int:offset}, {int:limit}',
array(
'regular_member' => 0,
'sort_method' => $sort_method,
'sort_direction' => $context['sort_direction'] == 'up' ? 'ASC' : 'DESC',
'offset' => $context['start'],
'limit' => $modSettings['defaultMaxMembers'],
)
);


replace:


$request = $smcFunc['db_query']('', '
SELECT
lo.log_time, lo.id_member, lo.url, INET6_NTOA(lo.ip) AS ip, mem.real_name,
lo.session, mg.online_color, IFNULL(mem.show_online, 1) AS show_online,
lo.id_spider
FROM {db_prefix}log_online AS lo
LEFT JOIN {db_prefix}members AS mem ON (lo.id_member = mem.id_member)
LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = CASE WHEN mem.id_group = {int:regular_member} THEN mem.id_post_group ELSE mem.id_group END)' . (!empty($conditions) ? '
WHERE ' . implode(' AND ', $conditions) : '') . '
ORDER BY {raw:sort_method} {raw:sort_direction}
LIMIT {int:offset}, {int:limit}',
array(
'regular_member' => 0,
'sort_method' => $sort_method,
'sort_direction' => $context['sort_direction'] == 'up' ? 'ASC' : 'DESC',
'offset' => $context['start'],
'limit' => $modSettings['defaultMaxMembers'],
)
);


Hope this will help some people.

NightWolve

#76
Quote from: wintstar on January 29, 2020, 06:42:21 AM
Bugs in database_install.php

find
// Do the loopy, loop, loe.
foreach ($changed_fields as $column_name => $column_attributes)
$smcFunc['db_change_column']($db_prefix . 'ban_items', $column_attributes);

replace with
// Do the loopy, loop, loe.
foreach ($changed_fields as $column_name => $column_attributes)
if (!in_array($column_name, $table_columns))
$smcFunc['db_change_column']($db_prefix . 'ban_items', $column_attributes);



There's another bug here  => $smcFunc['db_change_column']. The columns are not changed in the database table.  ::)  Maybe someone has a solution for that.

Yeah, thanks for that, I tried to install the mod, but it failed on  $smcFunc['db_change_column'] reporting that it takes 3 parameters, not 2... So I searched smf 2.0.18 clean source code to find examples of usage, and the 2nd parameter was the column name. It appears he simply forgot to add it, not that the function ever changed parameter requirements, so REALLY not trustworthy, but got no choice right now.

So the fix is:

Quote
foreach ($changed_fields as $column_name => $column_attributes)
   if (!in_array($column_name, $table_columns))
      $smcFunc['db_change_column']($db_prefix . 'ban_items', $column_name, $column_attributes);

And it did need your in_array check to install successfully! I'll add the above INET_ATON usages by Chomper as well! Thanks!

NightWolve

#77
Looks like there are only a few minutes before you can edit a post, so can't update my previous one.

I came back with a followup:

* Unless you're 1000% sure of yourself, don't bother with this mod. It was hackish/unfinished to begin with.

* Don't do any of Chomper's changes. That made regular IPv4 addresses invisible with 2.0.18.



* I just wanted IPv6 addresses visible in the Who's Online feature, and Track IP. I probably didn't have to bother with this outdated mod, I will just use htaccess for bans.

* So to make IPv6 show in WhoIs, the session field in "smf_log_online" is already fully recording it as a string from $_SERVER['REMOTE_ADDR'] (it's either prepended with 'ip' or an actual session ID if logged in), we just need a few changes thankfully!

Who.php


Find:
// Send the information to the template.
$context['members'][$row['session']] = array(
'id' => $row['id_member'],
'ip' => allowedTo('moderate_forum') ? $row['ip'] : '',


Change to:


$IPv6 = $row['session'] . '';
if ( substr($IPv6, 0, 2) == 'ip' )
$IPv6 = substr($IPv6, 2);
else
$IPv6 = $row['ip'];

// Send the information to the template.
$context['members'][$row['session']] = array(
'id' => $row['id_member'],
'ip' => allowedTo('moderate_forum') ? $IPv6 : '',



Then you just need to disable the IP4 regular expression check so the TrackIP feature goes thru in "Profile-View.php." You may have to change links to external GeoIP providers also.

Profile-View.php - Find the string 'invalid_tracking_ip' and comment out the check:


//if (preg_match('/^\d{1,3}\.(\d{1,3}|\*)\.(\d{1,3}|\*)\.(\d{1,3}|\*)$/', $context['ip']) == 0 && preg_match('~^((([0-9A-Fa-f*]{1,4}:){7}[0-9A-Fa-f*]{1,4})|(([0-9A-Fa-f*]{1,4}:){6}:[0-9A-Fa-f*]{1,4})|(([0-9A-Fa-f*]{1,4}:){5}:([0-9A-Fa-f*]{1,4}:)?[0-9A-Fa-f*]{1,4})|(([0-9A-Fa-f*]{1,4}:){4}:([0-9A-Fa-f*]{1,4}:){0,2}[0-9A-Fa-f*]{1,4})|(([0-9A-Fa-f*]{1,4}:){3}:([0-9A-Fa-f*]{1,4}:){0,3}[0-9A-Fa-f*]{1,4})|(([0-9A-Fa-f*]{1,4}:){2}:([0-9A-Fa-f*]{1,4}:){0,4}[0-9A-Fa-f*]{1,4})|(([0-9A-Fa-f*]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f*]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f*]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f*]{1,4}::([0-9A-Fa-f*]{1,4}:){0,5}[0-9A-Fa-f*]{1,4})|(::([0-9A-Fa-f*]{1,4}:){0,6}[0-9A-Fa-f*]{1,4})|(([0-9A-Fa-f*]{1,4}:){1,7}:))$~', $context['ip']) == 0)
//fatal_lang_error('invalid_tracking_ip', false);


This should be enough to at least let you view both IP4 & IP6 addresses in Who's Online without even installing this mod... It's hackish, sorry can't make it neat, but it might be enough to help out before upgrading to the new 2.1 core...

Never mind, session is not quite on IPv6 recording for guests, I fired off too early... Back to the drawing board....

LiBen

I tried to use the mod. But it turn out it unpacks into a 1-file not multiple files. Does anyone have anything that actually works to catch IPv6 on SMF2.0.18?

Advertisement: