mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-02 16:33:56 +08:00
🍓 Sync 2026-09-15 02:13:06
This commit is contained in:
1 parent
7872f8755a
commit
921c6ff346
146 files changed
+26541
-508
No files matched your search
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"admin/services/ssserver": {
|
||||
"title": "Shadowsocks Server",
|
||||
"action": {
|
||||
"type": "firstchild"
|
||||
},
|
||||
"order": 50
|
||||
},
|
||||
"admin/services/ssserver/overview": {
|
||||
"title": "Overview",
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "ssserver/overview"
|
||||
},
|
||||
"order": 10
|
||||
},
|
||||
"admin/services/ssserver/config": {
|
||||
"title": "Settings",
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "ssserver/config"
|
||||
},
|
||||
"order": 20
|
||||
},
|
||||
"admin/services/ssserver/log": {
|
||||
"title": "Log",
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "ssserver/log"
|
||||
},
|
||||
"order": 30
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"luci-app-ssserver": {
|
||||
"description": "Grant access to ssserver configuration and status",
|
||||
"read": {
|
||||
"ubus": {
|
||||
"luci.ssserver": [ "get_log", "get_ciphers", "get_tfo_status", "get_lan_ip", "get_status" ]
|
||||
},
|
||||
"uci": [ "ssserver", "firewall" ]
|
||||
},
|
||||
"write": {
|
||||
"ubus": {
|
||||
"luci.ssserver": [ "service_action" ]
|
||||
},
|
||||
"uci": [ "ssserver", "firewall" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
'use strict';
|
||||
|
||||
import { connect } from 'ubus';
|
||||
import * as fs from 'fs';
|
||||
|
||||
const methods = {
|
||||
get_log: {
|
||||
call: function() {
|
||||
let p = fs.popen('logread -e ssserver');
|
||||
let log = '';
|
||||
if (p) {
|
||||
log = p.read('all');
|
||||
p.close();
|
||||
}
|
||||
return { log: log };
|
||||
}
|
||||
},
|
||||
|
||||
get_ciphers: {
|
||||
call: function() {
|
||||
let ciphers = [];
|
||||
let p = fs.popen('/usr/bin/ssserver --help 2>&1');
|
||||
if (p) {
|
||||
let output = p.read('all');
|
||||
p.close();
|
||||
let start = index(output, '--encrypt-method');
|
||||
if (start >= 0) {
|
||||
let sub = substr(output, start);
|
||||
let res = match(sub, /possible values: (([^\]\r\n]|[\r\n])+)/);
|
||||
if (res) {
|
||||
let list = split(res[1], /,\s*/);
|
||||
for (let c in list) {
|
||||
let val = rtrim(ltrim(c));
|
||||
// Clean up possible newlines and extra spaces
|
||||
val = replace(val, /\s+/g, "");
|
||||
if (val) push(ciphers, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Fallback if parsing fails or returns nothing
|
||||
if (length(ciphers) == 0) {
|
||||
ciphers = [
|
||||
'chacha20-ietf-poly1305',
|
||||
'aes-256-gcm',
|
||||
'aes-128-gcm',
|
||||
'2022-blake3-aes-128-gcm',
|
||||
'2022-blake3-aes-256-gcm',
|
||||
'2022-blake3-chacha20-poly1305'
|
||||
];
|
||||
}
|
||||
return { ciphers: ciphers };
|
||||
}
|
||||
},
|
||||
|
||||
get_tfo_status: {
|
||||
call: function() {
|
||||
let val = rtrim(fs.readfile('/proc/sys/net/ipv4/tcp_fastopen') || '0');
|
||||
return { value: +val };
|
||||
}
|
||||
},
|
||||
|
||||
get_lan_ip: {
|
||||
call: function() {
|
||||
let u = connect();
|
||||
let ip = '';
|
||||
if (u) {
|
||||
let status = u.call('network.interface.lan', 'status');
|
||||
if (status && type(status['ipv4-address']) === 'array' && length(status['ipv4-address']) > 0) {
|
||||
ip = status['ipv4-address'][0].address;
|
||||
}
|
||||
u.disconnect();
|
||||
}
|
||||
return { ip: ip };
|
||||
}
|
||||
},
|
||||
|
||||
get_status: {
|
||||
call: function() {
|
||||
let u = connect();
|
||||
let running = false;
|
||||
let pid = null;
|
||||
if (u) {
|
||||
let res = u.call('service', 'list', { name: 'ssserver' });
|
||||
if (res && res.ssserver && res.ssserver.instances) {
|
||||
let inst = res.ssserver.instances.instance1;
|
||||
if (inst && inst.running) {
|
||||
running = true;
|
||||
pid = inst.pid;
|
||||
}
|
||||
}
|
||||
u.disconnect();
|
||||
}
|
||||
return { running: running, pid: pid };
|
||||
}
|
||||
},
|
||||
|
||||
service_action: {
|
||||
args: { action: '' },
|
||||
call: function(req) {
|
||||
let action = req.args?.action ?? '';
|
||||
if (action != 'start' && action != 'stop' && action != 'restart' && action != 'reload')
|
||||
return { success: false, error: 'invalid action' };
|
||||
let rc = system('/etc/init.d/ssserver ' + action + ' >/dev/null 2>&1');
|
||||
return { success: (rc === 0), applied: (rc === 0) };
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return { 'luci.ssserver': methods };
|
||||
Reference in new issue
Block a user