UNPKG

vpn.email.client

Version:
66 lines (58 loc) 1.49 kB
import * as Crypto from 'crypto' import * as hostProxy from './httpProxy' import * as Url from 'url' export interface hostListData { host: string security: number get: number post: number other: number, ipaddress: string } export class hostList { constructor ( private listPool: Map < string, hostListData >, private domainBlackList: string [] ) { } public putList ( urlData: hostProxy.httpProxy ) { const host = urlData.Url.hostname const data: hostListData = this.listPool.get ( host ) || { host : host, security: 0, get: 0, post: 0, other: 0, ipaddress: null, } if ( urlData.isConnect && urlData.Url.port === '443' ) data.security ++ else if ( urlData.isGet ) data.get ++ else if ( urlData.isPost ) data.post ++ else data.other ++ this.listPool.set ( host, data ) const nn = this.domainBlackList.find ( n => { return n === data.host }) return nn && nn.length } public putListSock5 ( host: string, urlData: hostProxy.httpProxy ) { const data = this.listPool.get ( host ) || { host : urlData && urlData.Url.hostname ? urlData.Url.hostname : null, ipaddress: host, security: 0, get: 0, post: 0, other: 0 } if ( !urlData ) data.security ++ else if ( urlData.isGet ) data.get ++ else if ( urlData.isPost ) data.post ++ else data.other ++ this.listPool.set ( host, data ) const nn = this.domainBlackList.find ( n => { return n === data.host }) return nn && nn.length } }