mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-12 17:07:51 +08:00
✨ Sync 2026-10-11 20:48:25
This commit is contained in:
1 parent
78f0ba8251
commit
5ce75c9f2b
45 files changed
+54
-879
No files matched your search
@@ -12,9 +12,6 @@
|
||||
'require uci';
|
||||
'require ui';
|
||||
|
||||
/* Shared wording for the TLS / transport form blocks. Keeping the strings here
|
||||
makes node.js and server.js consume a single definition instead of two
|
||||
copies that have to be edited in lockstep. */
|
||||
const TRANSPORT_NONE_HINT = _('No TCP transport, plain HTTP is merged into the HTTP transport.');
|
||||
const TRANSPORT_HTTP_HINT = _('TLS is not enforced. If TLS is not configured, plain HTTP 1.1 is used.');
|
||||
const TRANSPORT_QUIC_HINT = _('No additional encryption support: It\'s basically duplicate encryption.');
|
||||
@@ -38,28 +35,23 @@ return baseclass.extend({
|
||||
},
|
||||
|
||||
shadowsocks_encrypt_length: {
|
||||
/* AEAD */
|
||||
'aes-128-gcm': 0,
|
||||
'aes-192-gcm': 0,
|
||||
'aes-256-gcm': 0,
|
||||
'chacha20-ietf-poly1305': 0,
|
||||
'xchacha20-ietf-poly1305': 0,
|
||||
/* AEAD 2022 */
|
||||
'2022-blake3-aes-128-gcm': 16,
|
||||
'2022-blake3-aes-256-gcm': 32,
|
||||
'2022-blake3-chacha20-poly1305': 32
|
||||
},
|
||||
|
||||
shadowsocks_encrypt_methods: [
|
||||
/* Stream */
|
||||
'none',
|
||||
/* AEAD */
|
||||
'aes-128-gcm',
|
||||
'aes-192-gcm',
|
||||
'aes-256-gcm',
|
||||
'chacha20-ietf-poly1305',
|
||||
'xchacha20-ietf-poly1305',
|
||||
/* AEAD 2022 */
|
||||
'2022-blake3-aes-128-gcm',
|
||||
'2022-blake3-aes-256-gcm',
|
||||
'2022-blake3-chacha20-poly1305'
|
||||
@@ -102,10 +94,6 @@ return baseclass.extend({
|
||||
}
|
||||
}),
|
||||
|
||||
/* Build the transport option group shared by the node (client) and server
|
||||
forms. `options.side` selects the client/server wording and the handful of
|
||||
fields that only exist on one side; option names, defaults and dependency
|
||||
sets are otherwise identical. */
|
||||
renderTransportOptions(section, options) {
|
||||
const features = options.features || {},
|
||||
side = options.side || 'client';
|
||||
@@ -236,10 +224,6 @@ return baseclass.extend({
|
||||
return o;
|
||||
},
|
||||
|
||||
/* Build the TLS option group shared by the node (client) and server forms.
|
||||
`options.type_depends` lists the node types the TLS flag applies to,
|
||||
`options.tls_forced_types` the types that force TLS on, and
|
||||
`options.oninsecurechange` the client-side confirm handler. */
|
||||
renderTlsOptions(section, options) {
|
||||
const side = options.side || 'client';
|
||||
let o;
|
||||
@@ -323,7 +307,6 @@ return baseclass.extend({
|
||||
},
|
||||
|
||||
calcStringMD5(e) {
|
||||
/* Thanks to https://stackoverflow.com/a/41602636 */
|
||||
let h = (a, b) => {
|
||||
let c, d, e, f, g;
|
||||
c = a & 2147483648;
|
||||
@@ -400,7 +383,6 @@ return baseclass.extend({
|
||||
if (!str)
|
||||
return null;
|
||||
|
||||
/* Thanks to luci-app-ssr-plus */
|
||||
str = str.replace(/-/g, '+').replace(/_/g, '/');
|
||||
let padding = (4 - str.length % 4) % 4;
|
||||
if (padding)
|
||||
@@ -427,14 +409,12 @@ return baseclass.extend({
|
||||
byteArr = crypto.getRandomValues(new Uint8Array(length));
|
||||
switch (type) {
|
||||
case 'base64':
|
||||
/* Thanks to https://stackoverflow.com/questions/9267899 */
|
||||
return btoa(String.fromCharCode.apply(null, byteArr));
|
||||
case 'hex':
|
||||
return Array.from(byteArr, (byte) =>
|
||||
(byte & 255).toString(16).padStart(2, '0')
|
||||
).join('');
|
||||
case 'uuid':
|
||||
/* Thanks to https://stackoverflow.com/a/2117523 */
|
||||
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, (c) =>
|
||||
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
|
||||
);
|
||||
@@ -501,7 +481,6 @@ return baseclass.extend({
|
||||
},
|
||||
|
||||
validateBase64Key(length, section_id, value) {
|
||||
/* Thanks to luci-proto-wireguard */
|
||||
if (section_id && value)
|
||||
if (value.length !== length || !value.match(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/) || value[length-1] !== '=')
|
||||
return _('Expecting: %s').format(_('valid base64 key with %d characters').format(length));
|
||||
@@ -526,7 +505,6 @@ return baseclass.extend({
|
||||
else if (!value[2])
|
||||
value[2] = 65535;
|
||||
|
||||
/* numeric comparison: string '<' does lexicographic ordering */
|
||||
if (parseInt(value[1], 10) < parseInt(value[2], 10) && value[2] <= 65535)
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user