init server python để điều khiển adb

This commit is contained in:
Victor Phan
2026-07-21 08:54:30 +07:00
parent d36007d989
commit 7625bdd37b
1557 changed files with 326 additions and 53 deletions
+666
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+67
View File
@@ -0,0 +1,67 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = suffixLookup;
const tldts_core_1 = require("tldts-core");
const trie_1 = require("./data/trie");
/**
* Lookup parts of domain in Trie
*/
function lookupInTrie(parts, trie, index, allowedMask) {
let result = null;
let node = trie;
while (node !== undefined) {
// We have a match!
if ((node[0] & allowedMask) !== 0) {
result = {
index: index + 1,
isIcann: node[0] === 1 /* RULE_TYPE.ICANN */,
isPrivate: node[0] === 2 /* RULE_TYPE.PRIVATE */,
};
}
// No more `parts` to look for
if (index === -1) {
break;
}
const succ = node[1];
node = Object.prototype.hasOwnProperty.call(succ, parts[index])
? succ[parts[index]]
: succ['*'];
index -= 1;
}
return result;
}
/**
* Check if `hostname` has a valid public suffix in `trie`.
*/
function suffixLookup(hostname, options, out) {
var _a;
if ((0, tldts_core_1.fastPathLookup)(hostname, options, out)) {
return;
}
const hostnameParts = hostname.split('.');
const allowedMask = (options.allowPrivateDomains ? 2 /* RULE_TYPE.PRIVATE */ : 0) |
(options.allowIcannDomains ? 1 /* RULE_TYPE.ICANN */ : 0);
// Look for exceptions
const exceptionMatch = lookupInTrie(hostnameParts, trie_1.exceptions, hostnameParts.length - 1, allowedMask);
if (exceptionMatch !== null) {
out.isIcann = exceptionMatch.isIcann;
out.isPrivate = exceptionMatch.isPrivate;
out.publicSuffix = hostnameParts.slice(exceptionMatch.index + 1).join('.');
return;
}
// Look for a match in rules
const rulesMatch = lookupInTrie(hostnameParts, trie_1.rules, hostnameParts.length - 1, allowedMask);
if (rulesMatch !== null) {
out.isIcann = rulesMatch.isIcann;
out.isPrivate = rulesMatch.isPrivate;
out.publicSuffix = hostnameParts.slice(rulesMatch.index).join('.');
return;
}
// No match found...
// Prevailing rule is '*' so we consider the top-level domain to be the
// public suffix of `hostname` (e.g.: 'example.org' => 'org').
out.isIcann = false;
out.isPrivate = false;
out.publicSuffix = (_a = hostnameParts[hostnameParts.length - 1]) !== null && _a !== void 0 ? _a : null;
}
//# sourceMappingURL=suffix-trie.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"suffix-trie.js","sourceRoot":"","sources":["../../../src/suffix-trie.ts"],"names":[],"mappings":";;AA0DA,+BAmDC;AA7GD,2CAIoB;AACpB,sCAAuD;AAcvD;;GAEG;AACH,SAAS,YAAY,CACnB,KAAe,EACf,IAAW,EACX,KAAa,EACb,WAAmB;IAEnB,IAAI,MAAM,GAAkB,IAAI,CAAC;IACjC,IAAI,IAAI,GAAsB,IAAI,CAAC;IACnC,OAAO,IAAI,KAAK,SAAS,EAAE,CAAC;QAC1B,mBAAmB;QACnB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;YAClC,MAAM,GAAG;gBACP,KAAK,EAAE,KAAK,GAAG,CAAC;gBAChB,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,4BAAoB;gBACpC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,8BAAsB;aACzC,CAAC;QACJ,CAAC;QAED,8BAA8B;QAC9B,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;YACjB,MAAM;QACR,CAAC;QAED,MAAM,IAAI,GAA+B,IAAI,CAAC,CAAC,CAAC,CAAC;QACjD,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAE,CAAC;YAC9D,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAE,CAAC;YACrB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACd,KAAK,IAAI,CAAC,CAAC;IACb,CAA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,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACnE,OAAO;IACT,CAAC;IAED,oBAAoB;IACpB,uEAAuE;IACvE,8DAA8D;IAC9D,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC;IACpB,GAAG,CAAC,SAAS,GAAG,KAAK,CAAC;IACtB,GAAG,CAAC,YAAY,GAAG,MAAA,aAAa,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,mCAAI,IAAI,CAAC;AACrE,CAAC"}
File diff suppressed because one or more lines are too long
+33
View File
@@ -0,0 +1,33 @@
import { getEmptyResult, parseImpl, resetResult, } from 'tldts-core';
import suffixLookup from './src/suffix-trie';
// For all methods but 'parse', it does not make sense to allocate an object
// every single time to only return the value of a specific attribute. To avoid
// this un-necessary allocation, we use a global object which is re-used.
const RESULT = getEmptyResult();
export function parse(url, options = {}) {
return parseImpl(url, 5 /* FLAG.ALL */, suffixLookup, options, getEmptyResult());
}
export function getHostname(url, options = {}) {
/*@__INLINE__*/ resetResult(RESULT);
return parseImpl(url, 0 /* FLAG.HOSTNAME */, suffixLookup, options, RESULT).hostname;
}
export function getPublicSuffix(url, options = {}) {
/*@__INLINE__*/ resetResult(RESULT);
return parseImpl(url, 2 /* FLAG.PUBLIC_SUFFIX */, suffixLookup, options, RESULT)
.publicSuffix;
}
export function getDomain(url, options = {}) {
/*@__INLINE__*/ resetResult(RESULT);
return parseImpl(url, 3 /* FLAG.DOMAIN */, suffixLookup, options, RESULT).domain;
}
export function getSubdomain(url, options = {}) {
/*@__INLINE__*/ resetResult(RESULT);
return parseImpl(url, 4 /* FLAG.SUB_DOMAIN */, suffixLookup, options, RESULT)
.subdomain;
}
export function getDomainWithoutSuffix(url, options = {}) {
/*@__INLINE__*/ resetResult(RESULT);
return parseImpl(url, 5 /* FLAG.ALL */, suffixLookup, options, RESULT)
.domainWithoutSuffix;
}
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","source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UAAU,sBAAsB,CACpC,GAAW,EACX,UAA6B,EAAE;IAE/B,eAAe,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,OAAO,SAAS,CAAC,GAAG,oBAAY,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC;SAC3D,mBAAmB,CAAC;AACzB,CAAC"}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+64
View File
@@ -0,0 +1,64 @@
import { fastPathLookup, } from 'tldts-core';
import { exceptions, rules } from './data/trie';
/**
* Lookup parts of domain in Trie
*/
function lookupInTrie(parts, trie, index, allowedMask) {
let result = null;
let node = trie;
while (node !== undefined) {
// We have a match!
if ((node[0] & allowedMask) !== 0) {
result = {
index: index + 1,
isIcann: node[0] === 1 /* RULE_TYPE.ICANN */,
isPrivate: node[0] === 2 /* RULE_TYPE.PRIVATE */,
};
}
// No more `parts` to look for
if (index === -1) {
break;
}
const succ = node[1];
node = Object.prototype.hasOwnProperty.call(succ, parts[index])
? succ[parts[index]]
: succ['*'];
index -= 1;
}
return result;
}
/**
* Check if `hostname` has a valid public suffix in `trie`.
*/
export default function suffixLookup(hostname, options, out) {
var _a;
if (fastPathLookup(hostname, options, out)) {
return;
}
const hostnameParts = hostname.split('.');
const allowedMask = (options.allowPrivateDomains ? 2 /* RULE_TYPE.PRIVATE */ : 0) |
(options.allowIcannDomains ? 1 /* RULE_TYPE.ICANN */ : 0);
// Look for exceptions
const exceptionMatch = lookupInTrie(hostnameParts, exceptions, hostnameParts.length - 1, allowedMask);
if (exceptionMatch !== null) {
out.isIcann = exceptionMatch.isIcann;
out.isPrivate = exceptionMatch.isPrivate;
out.publicSuffix = hostnameParts.slice(exceptionMatch.index + 1).join('.');
return;
}
// Look for a match in rules
const rulesMatch = lookupInTrie(hostnameParts, rules, hostnameParts.length - 1, allowedMask);
if (rulesMatch !== null) {
out.isIcann = rulesMatch.isIcann;
out.isPrivate = rulesMatch.isPrivate;
out.publicSuffix = hostnameParts.slice(rulesMatch.index).join('.');
return;
}
// No match found...
// Prevailing rule is '*' so we consider the top-level domain to be the
// public suffix of `hostname` (e.g.: 'example.org' => 'org').
out.isIcann = false;
out.isPrivate = false;
out.publicSuffix = (_a = hostnameParts[hostnameParts.length - 1]) !== null && _a !== void 0 ? _a : null;
}
//# sourceMappingURL=suffix-trie.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"suffix-trie.js","sourceRoot":"","sources":["../../../src/suffix-trie.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,GAGf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,UAAU,EAAS,KAAK,EAAE,MAAM,aAAa,CAAC;AAcvD;;GAEG;AACH,SAAS,YAAY,CACnB,KAAe,EACf,IAAW,EACX,KAAa,EACb,WAAmB;IAEnB,IAAI,MAAM,GAAkB,IAAI,CAAC;IACjC,IAAI,IAAI,GAAsB,IAAI,CAAC;IACnC,OAAO,IAAI,KAAK,SAAS,EAAE,CAAC;QAC1B,mBAAmB;QACnB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;YAClC,MAAM,GAAG;gBACP,KAAK,EAAE,KAAK,GAAG,CAAC;gBAChB,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,4BAAoB;gBACpC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,8BAAsB;aACzC,CAAC;QACJ,CAAC;QAED,8BAA8B;QAC9B,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;YACjB,MAAM;QACR,CAAC;QAED,MAAM,IAAI,GAA+B,IAAI,CAAC,CAAC,CAAC,CAAC;QACjD,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAE,CAAC;YAC9D,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAE,CAAC;YACrB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,C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AC,YAAY,GAAG,aAAa,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACnE,OAAO;IACT,CAAC;IAED,oBAAoB;IACpB,uEAAuE;IACvE,8DAA8D;IAC9D,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC;IACpB,GAAG,CAAC,SAAS,GAAG,KAAK,CAAC;IACtB,GAAG,CAAC,YAAY,GAAG,MAAA,aAAa,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,mCAAI,IAAI,CAAC;AACrE,CAAC"}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+7
View File
@@ -0,0 +1,7 @@
import { IOptions, IResult } from 'tldts-core';
export declare function parse(url: string, options?: Partial<IOptions>): IResult;
export declare function getHostname(url: string, options?: Partial<IOptions>): string | null;
export declare function getPublicSuffix(url: string, options?: Partial<IOptions>): string | null;
export declare function getDomain(url: string, options?: Partial<IOptions>): string | null;
export declare function getSubdomain(url: string, options?: Partial<IOptions>): string | null;
export declare function getDomainWithoutSuffix(url: string, options?: Partial<IOptions>): string | null;
+5
View File
@@ -0,0 +1,5 @@
export type ITrie = [0 | 1 | 2, {
[label: string]: ITrie;
}];
export declare const exceptions: ITrie;
export declare const rules: ITrie;
+5
View File
@@ -0,0 +1,5 @@
import { IPublicSuffix, ISuffixLookupOptions } from 'tldts-core';
/**
* Check if `hostname` has a valid public suffix in `trie`.
*/
export default function suffixLookup(hostname: string, options: ISuffixLookupOptions, out: IPublicSuffix): void;