public
nobgit
read
NobMail
Based on mailcow: dockerized
Languages
Repository composition by tracked source files.
PHP
49%
JavaScript
35%
HTML
9%
CSS
4%
Shell
2%
Python
1%
Lua
0%
Perl
0%
Ruby
0%
SCSS
0%
Create file
Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git
Trace
data/conf/rspamd/dynmaps/forwardinghosts.php
Trace helps you understand code history line by line. See who changed each line, when it changed, and which commit introduced it.
Author
Date
Commit
Line
Code
1
<?php
2
header('Content-Type: text/plain');
3
ini_set('error_reporting', 0);
5
$redis = new Redis();
6
$redis->connect('redis-mailcow', 6379);
7
$redis->auth(getenv("REDISPASS"));
9
function in_net($addr, $net) {
10
$net = explode('/', $net);
11
if (count($net) > 1) {
12
$mask = $net[1];
13
}
14
$net = inet_pton($net[0]);
15
$addr = inet_pton($addr);
16
$length = strlen($net); // 4 for IPv4, 16 for IPv6
17
if (strlen($net) != strlen($addr)) {
18
return false;
19
}
20
if (!isset($mask)) {
21
$mask = $length * 8;
22
}
23
$addr_bin = '';
24
$net_bin = '';
25
for ($i = 0; $i < $length; ++$i) {
26
$addr_bin .= str_pad(decbin(ord(substr($addr, $i, $i+1))), 8, '0', STR_PAD_LEFT);
27
$net_bin .= str_pad(decbin(ord(substr($net, $i, $i+1))), 8, '0', STR_PAD_LEFT);
28
}
29
return substr($addr_bin, 0, $mask) == substr($net_bin, 0, $mask);
30
}
32
if (isset($_GET['host'])) {
33
try {
34
foreach ($redis->hGetAll('WHITELISTED_FWD_HOST') as $host => $source) {
35
if (in_net($_GET['host'], $host)) {
36
echo '200 PERMIT';
37
exit;
38
}
39
}
40
echo '200 DUNNO';
41
}
42
catch (RedisException $e) {
43
echo '200 DUNNO';
44
exit;
45
}
46
} else {
47
try {
48
echo '240.240.240.240' . PHP_EOL;
49
foreach ($redis->hGetAll('WHITELISTED_FWD_HOST') as $host => $source) {
50
echo $host . PHP_EOL;
51
}
52
}
53
catch (RedisException $e) {
54
echo '240.240.240.240' . PHP_EOL;
55
exit;
56
}
57
}
58
?>