MediaWiki
REL1_39
ProxyLookup.php
Go to the documentation of this file.
1
<?php
2
22
use
MediaWiki\HookContainer\HookContainer
;
23
use
MediaWiki\HookContainer\HookRunner
;
24
use Wikimedia\IPSet;
25
29
class
ProxyLookup
{
30
32
private
$proxyServers;
33
35
private
$proxyServersComplex;
36
38
private
$proxyIPSet;
39
41
private
$hookRunner;
42
48
public
function
__construct
(
49
$proxyServers,
50
$proxyServersComplex,
51
HookContainer
$hookContainer
52
) {
53
$this->proxyServers = $proxyServers;
54
$this->proxyServersComplex = $proxyServersComplex;
55
$this->hookRunner =
new
HookRunner
( $hookContainer );
56
}
57
64
public
function
isConfiguredProxy
( $ip ) {
65
// Quick check of known singular proxy servers
66
if
( in_array( $ip, $this->proxyServers,
true
) ) {
67
return
true
;
68
}
69
70
// Check against addresses and CIDR nets in the complex list
71
if
( !$this->proxyIPSet ) {
72
$this->proxyIPSet =
new
IPSet( $this->proxyServersComplex );
73
}
74
return
$this->proxyIPSet->match( $ip );
75
}
76
85
public
function
isTrustedProxy
( $ip ) {
86
$trusted = $this->
isConfiguredProxy
( $ip );
87
$this->hookRunner->onIsTrustedProxy( $ip, $trusted );
88
return
$trusted;
89
}
90
}
MediaWiki\HookContainer\HookContainer
HookContainer class.
Definition
HookContainer.php:45
MediaWiki\HookContainer\HookRunner
This class provides an implementation of the core hook interfaces, forwarding hook calls to HookConta...
Definition
HookRunner.php:565
ProxyLookup
Definition
ProxyLookup.php:29
ProxyLookup\__construct
__construct( $proxyServers, $proxyServersComplex, HookContainer $hookContainer)
Definition
ProxyLookup.php:48
ProxyLookup\isTrustedProxy
isTrustedProxy( $ip)
Checks if an IP is a trusted proxy provider.
Definition
ProxyLookup.php:85
ProxyLookup\isConfiguredProxy
isConfiguredProxy( $ip)
Checks if an IP matches a proxy we've configured.
Definition
ProxyLookup.php:64
includes
ProxyLookup.php
Generated on Mon Dec 23 2024 06:24:16 for MediaWiki by
1.10.0