INNER CODE UNIT · JavaScript
addAccount
shadowsocks/shadowsocks-manager · plugins/account/index.js:31
const addAccount = async (type, options) => {
let key;
try {
const privateKey = await runCommand('wg genkey');
const publicKey = await runCommand(`echo '${ privateKey.trim() }' | wg pubkey`);
key = publicKey.trim() + ':' + privateKey.trim();
} catch(err) {}
if(!options.hasOwnProperty('active')) { options.active = 1; }
if(type === 6 || type === 7) {
type = 3;
}
const subscribeToken = crypto.randomBytes(16).toString('hex');
if(type === 1) {
const [ accountId ] = await knex('account_plugin').insert({
type,
orderId: 0,
userId: options.user,
port: options.port,