forked from ppfun/pixelplanet
more fixes
This commit is contained in:
parent
2b82971ceb
commit
a5d25a8217
|
@ -50,7 +50,7 @@ function ModIIDtools() {
|
|||
selectIIDAction(sel.options[sel.selectedIndex].value);
|
||||
}}
|
||||
>
|
||||
{['givecaptcha', 'ban', 'unban', 'whitelist', 'unwhitelist']
|
||||
{['status', 'givecaptcha', 'ban', 'unban', 'whitelist', 'unwhitelist']
|
||||
.map((opt) => (
|
||||
<option
|
||||
key={opt}
|
||||
|
|
|
@ -13,15 +13,7 @@ import Palette from './Palette';
|
|||
import Alert from './Alert';
|
||||
import HistorySelect from './HistorySelect';
|
||||
import Mobile3DControls from './Mobile3DControls';
|
||||
import UserContextMenu from './contextmenus/UserContextMenu';
|
||||
import ChannelContextMenu from './contextmenus/ChannelContextMenu';
|
||||
|
||||
|
||||
const CONTEXT_MENUS = {
|
||||
USER: UserContextMenu,
|
||||
CHANNEL: ChannelContextMenu,
|
||||
/* other context menus */
|
||||
};
|
||||
import ContextMenues from './contextmenus';
|
||||
|
||||
const UI = () => {
|
||||
const [
|
||||
|
@ -38,7 +30,7 @@ const UI = () => {
|
|||
state.contextMenu.menuType,
|
||||
], shallowEqual);
|
||||
|
||||
const ContextMenu = menuOpen && menuType && CONTEXT_MENUS[menuType];
|
||||
const ContextMenu = menuOpen && menuType && ContextMenues[menuType];
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
7
src/components/contextmenus/index.js
Normal file
7
src/components/contextmenus/index.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
import UserContextMenu from './UserContextMenu';
|
||||
import ChannelContextMenu from './ChannelContextMenu';
|
||||
|
||||
export default {
|
||||
USER: UserContextMenu,
|
||||
CHANNEL: ChannelContextMenu,
|
||||
};
|
|
@ -94,10 +94,12 @@ async function dummy() {
|
|||
return [false, 'dummy'];
|
||||
}
|
||||
|
||||
async function saveIPInfo(ip, isProxy, info) {
|
||||
async function saveIPInfo(ip, whoisRet, isProxy, info) {
|
||||
const whoisData = whoisRet || {};
|
||||
|
||||
try {
|
||||
const whoisData = await whois(ip);
|
||||
IPInfo.upsert({
|
||||
ip,
|
||||
...whoisData,
|
||||
isProxy,
|
||||
pcheck: info,
|
||||
|
@ -113,24 +115,32 @@ async function saveIPInfo(ip, isProxy, info) {
|
|||
* @param ip IP to check
|
||||
* @return true if proxy or blacklisted, false if not or whitelisted
|
||||
*/
|
||||
async function withoutCache(f, ip) {
|
||||
export async function withoutCache(f, ip) {
|
||||
const ipKey = getIPv6Subnet(ip);
|
||||
let allowed;
|
||||
let status;
|
||||
let pcInfo;
|
||||
if (await isWhitelisted(ipKey)) {
|
||||
allowed = false;
|
||||
pcInfo = 'wl';
|
||||
status = -1;
|
||||
} else if (await isIPBanned(ipKey)) {
|
||||
allowed = true;
|
||||
pcInfo = 'bl';
|
||||
status = 2;
|
||||
} else {
|
||||
[allowed, pcInfo] = await f(ip);
|
||||
status = (allowed) ? 1 : 0;
|
||||
let allowed = true;
|
||||
let status = -2;
|
||||
let pcInfo = null;
|
||||
let whoisRet = null;
|
||||
|
||||
try {
|
||||
if (await isWhitelisted(ipKey)) {
|
||||
allowed = true;
|
||||
pcInfo = 'wl';
|
||||
status = -1;
|
||||
} else if (await isIPBanned(ipKey)) {
|
||||
allowed = false;
|
||||
pcInfo = 'bl';
|
||||
status = 2;
|
||||
} else {
|
||||
[allowed, pcInfo] = await f(ip);
|
||||
allowed = !allowed;
|
||||
status = (allowed) ? 0 : 1;
|
||||
}
|
||||
whoisRet = await whois(ip);
|
||||
} finally {
|
||||
await saveIPInfo(ipKey, whoisRet, allowed, pcInfo);
|
||||
}
|
||||
saveIPInfo(ipKey, allowed, pcInfo);
|
||||
|
||||
return {
|
||||
allowed,
|
||||
status,
|
||||
|
|
|
@ -272,9 +272,9 @@ export async function getSummaryFromArea(
|
|||
}
|
||||
}
|
||||
row.push(
|
||||
ipInfo.uuid || 'N/A',
|
||||
ipInfo.country || 'xx',
|
||||
ipInfo.cidr || 'N/A',
|
||||
ipInfo.uuid,
|
||||
ipInfo.country,
|
||||
ipInfo.cidr,
|
||||
ipInfo.org || 'N/A',
|
||||
pcheck || 'N/A',
|
||||
);
|
||||
|
|
|
@ -23,6 +23,7 @@ const IPInfo = sequelize.define('IPInfo', {
|
|||
|
||||
cidr: {
|
||||
type: DataTypes.CHAR(43),
|
||||
defaultValue: 'N/A',
|
||||
allowNull: false,
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user