Commit graph

91 commits

Author SHA1 Message Date
Aaron
456177bdee [IP] Added an IP::prettifyIP() function for displaying IPs.
Change-Id: I53b3fe70bd0091ef02740f2b8950c36a0e4cf32e
2012-05-11 10:53:14 -07:00
Sam Reed
85bbb0b080 Fixing some of the "@return true" or "@return false", need to be "@return bool" and then the metadata can say true if foo, false if bar
Other documentation improvements
2012-02-09 18:01:10 +00:00
Antoine Musso
c1f23144e1 using real identity for hashar
Converting my pseudonym to use my real identity instead:
Ashar Voultoiz -> Antoine Musso
2011-10-24 09:08:13 +00:00
Aaron Schulz
c47386e27e Tweak r98602: keep the other IP normalization for non-ranges, such as upper case for v6. This keeps it a bit more consistent. 2011-10-01 05:11:21 +00:00
Aaron Schulz
9ac53dcc3b Made provideIPCIDRs() not add a '/' if there is no prefix length. Fixes bug 31234. 2011-10-01 04:54:44 +00:00
Aaron Schulz
1ec49ff3d3 Fixed typo in ipv6 private IP range list and added test (bug 30739) 2011-09-06 23:15:42 +00:00
Sam Reed
ad39f2da86 Trim trailing whitespace
Add/tweak/update documentation

Simplify some boolean returns
2011-09-04 21:40:17 +00:00
Tim Starling
6a2123260b * (bug 28798) Set $wgServer in the default LocalSettings.php
* (bug 14977) When detecting $wgServer, treat IPv6 addresses in $_SERVER['SERVER_NAME'] etc. in a sensible way. 
* Tests for the new functions in IP.php and Installer.php
2011-06-15 07:35:47 +00:00
Happy-melon
99f39a4779 Move Block::normaliseRange() to IP.php, then reduce it to 4 lines by using the existing functionality in that class. 2011-03-18 23:28:23 +00:00
Aaron Schulz
7fe32a2fa2 Follow-up r82093: fixed comment :) 2011-02-13 23:30:26 +00:00
Aaron Schulz
f65ce02ff9 * (bug 27353) IPv6 address ending in "::WORD" was not recognized
* Moved down 'contains no "::"' alternative for clarity (and possibly use frequency too)
* Added more IPv6 tests
2011-02-13 23:24:48 +00:00
Mark A. Hershberger
a465346c6e random w/s cleanup 2010-12-01 20:22:45 +00:00
Aaron Schulz
fb574da0ab *(bug 25920) Moved forward ref to a back ref to really get v6 regex to compile on older PCRE versions. Works around PCRE 8 nested named ref bug that killed r76928.
* Added another simple v6 assertion
2010-11-21 10:49:54 +00:00
Sam Reed
9a301f1636 Reverting r76928, causes segfault 2010-11-18 02:32:58 +00:00
Aaron Schulz
d0977b26a3 (bug 25920) Moved forward ref to a nested ref to really get v6 regex to compile on older PCRE versions 2010-11-18 00:25:58 +00:00
Aaron Schulz
52a79f37a1 * Reduced some pointless regex capture overhead
* Made preg_replace calls easier to verify w.r.t. captures
* (bug 25920) Made RE_IPV6_ADD avoid conditions on whether a named group matched anything, which requires PCRE 6.7+ (not bundled with PHP 5.1.0)
2010-11-17 09:12:18 +00:00
Alexandre Emsenhuber
386b748ca2 Fixed some doxygen warnings 2010-11-16 20:14:13 +00:00
Aaron Schulz
a34cccd8b1 Removed weird unused "IPv4toIPv6" function 2010-11-15 23:20:23 +00:00
Aaron Schulz
d7f0e354dd typo: RE_IPV4_BLOCK -> RE_IP_BLOCK 2010-11-15 20:37:11 +00:00
Aaron Schulz
3994a3b2e3 Minor cleanups 2010-11-13 23:31:13 +00:00
Aaron Schulz
21e317191b * parseCIDR() should use parseCIDR6() for IPv6 (plus the later is private since r76560...)
* Made parseRange() work for IPv6 "x - y" style ranges
* Added MWException to IPv4toIPv6()
2010-11-12 20:08:27 +00:00
Aaron Schulz
426f30bcfe * Removed redundant check in toUnsigned6().
* MW requires PHP 5.1+, so the -1/false ip2long annoyance is gone. Also, ip2long("255.255.255.255") is -1 so no special case code is needed anymore.
* Removed toSigned() (not used outside IP.php). Due to the above points, ip2long() is totally equilivant.
* Moved some functions and consts around.
* Comment tweaks.
2010-11-12 19:37:37 +00:00
Aaron Schulz
ff84f68f6a * Changes in IP.php:
** Fixed hexToOctet()/toOctet() padding (pad left not right)
** Made hexToQuad() left-pad input (e.g. C -> 0000000C)
** Added isPublic6() function (checked as needed by isPublic())
** Rewrote isValidBlock() to not do flaky and roundabout isArray() check. Works for v6 now.
** Removed toArray(), unused outside IP.php and broken for v6
** Removed toOctet() duplication
** Added new private IPv6ToRawHex() function. Used to make toHex() faster.
** Made some functions private
** Reverted r20435, pointless
** Updated credits
* Changes in IPTests:
** Added a bunch of tests (mostly v6)
** Removed weird array test (especially with toArray() gone) after r76514
** Padding *no* longer needed for hexToX functions - assertion flipped
* CheckUser: removed parseRange6() reference (now private)
2010-11-12 01:33:46 +00:00
Aaron Schulz
1a058cafed * Return type cleanup (int -> bool)
* Improved doc comments
2010-11-11 13:45:24 +00:00
Aaron Schulz
cd9108e37f * Followed-up r76267:
** Made RE_IPV6_ADD and sanitizeIP() hande '::'.
** RE_IPV6_ADD is no longer over-inclusive (# of octets and '::' must be valid)
* Removed weird debugging code
* Broke long line
2010-11-11 12:18:28 +00:00
Aaron Schulz
8090e523a2 Made sanitizeIP() handle CIDR IPs in IPv6 (fixes server-side stuff for bug 24293) 2010-11-07 21:53:26 +00:00
Aaron Schulz
521d3c4676 * Fixed RE_IPV6_ADD for IP networks ending in "::", like "abcd::/y" or "a::/y"
* Fixed formatHex() for IPv6 by handling prefix properly
* hextoOctet -> hexToOctet
* Assorted code cleanups (mostly with $bits/$network)
* Improved various code comments/docs
2010-11-07 20:31:48 +00:00
Alexandre Emsenhuber
85e0c158ee * Standardised file description headers
* added @file where needed
* added file description headers where needed
2010-10-23 14:16:26 +00:00
Antoine Musso
9e3b90a94d update my personal email address altern.org -> free.fr 2010-09-26 15:52:51 +00:00
Jack Phoenix
92ef4ae4e8 coding style tweaks 2010-08-08 16:57:31 +00:00
Alexandre Emsenhuber
5be509b0c1 * Standardised file description headers
* Added some descriptions
* Added @file where needed
2010-08-08 14:23:14 +00:00
Alexandre Emsenhuber
ef9787a85f * Fixed some doxygen warnings
* Removed some useless spaces in the begining of lines
2010-03-09 21:51:05 +00:00
OverlordQ
a989843cd0 Code cleanup, covert leading spaces into tabs per coding style 2009-11-14 21:27:13 +00:00
Aaron Schulz
2e89016676 Take the IPv4 part of mapped addresses rather than broken '.'->':' replace 2009-08-08 01:22:15 +00:00
Aaron Schulz
418e7767b4 IPv6 padding cleanup - removed trailing ':' 2009-07-27 07:03:36 +00:00
Aaron Schulz
c0a1b76624 * IPv6 validation check fix for bug 19003
* Made regexps a bit more readable by breaking lines
2009-07-27 06:08:41 +00:00
Roan Kattouw
d99df49ed7 Fixes for r51236 per CR comments 2009-05-31 15:02:43 +00:00
Roan Kattouw
e7f76a6e77 Fix weird bug that caused IP::isInRange("80.0.0.0", "94.0.0.0/24") to return true because "52000000" >= "5E000000" (52000000 >= 5). Thanks, PHP. 2009-05-31 14:52:16 +00:00
Tim Starling
c954755878 Changes required by the current version of SecurePoll:
* Add IP::formatHex(), the inverse of IP::toHex(). So that you don't have to guess if it's IPv4 or IPv6.
* Rewrite IP::hexToQuad() so it actually works.
2009-04-01 08:54:17 +00:00
Aaron Schulz
3337669b0c * Fix comment
* Rename HexToIP -> HexToQuad
2008-11-02 18:35:58 +00:00
Aryeh Gregor
565fe1cac3 Use MediaWiki whitespace standards, please.
This file is really a mess, though.  We need a unified system of
functions that will autodetect any IP address format and convert to any
desired format, not this hodgepodge of inconsistently-named and
inconsistently-operating hacks.
2008-11-02 17:17:19 +00:00
Roan Kattouw
db6d1ed1dc API: Move ApiQueryBlocks::convertHexIP() to IP::hexToIP() per Werdna's comment on r43040 2008-11-02 16:50:59 +00:00
Siebrand Mazeland
798f535951 * Fix common spelling error (seperate -> separate) 2008-09-15 20:38:27 +00:00
Aaron Schulz
bf388f2ee3 remove extra parenthesis 2008-08-24 22:50:12 +00:00
Aaron Schulz
67430027dc update comment 2008-08-13 23:34:56 +00:00
Aaron Schulz
6e15e8506e add HexToOct() 2008-08-13 16:51:37 +00:00
Brion Vibber
a31753e542 * (bug 15049) Fix for CheckUser extension's log search: usernames containing
a "-" were incorrectly turned into bogus IP range searches.
  Patch by Max Semenik.
2008-08-06 20:54:27 +00:00
Siebrand Mazeland
79d5225c0e * remove end of line whitespace
* remove empty lines at end of file
* remove "?>" where still present
2008-04-14 07:45:50 +00:00
Aaron Schulz
71b3ec988e *Convert '.' to ':' for IPs that have both (like '::eff:1.4.0.3')
*Expand IP dbkeys like "::fff:3e" rather than complain about the double colons
2007-09-03 16:36:25 +00:00
Brion Vibber
977977e314 * Fixed regression in blocking of username '0'
IP::sanitizeIP() for some reason is used to return IP-or-something-that's-not-an-IP, but was incorrectly checking for empties. Thus for '0' input it returned NULL instead of '0'.
2007-08-03 08:51:55 +00:00