Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add plugin support for freeAccount #675

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions plugins/freeAccount/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const address = config.plugins.freeAccount.address;
const method = config.plugins.freeAccount.method;
const analytics = config.plugins.freeAccount.analytics || '';
const password = config.plugins.freeAccount.password || '';
const plugin = config.plugins.freeAccount.plugin ? `/?plugin=${config.plugins.freeAccount.plugin};${(config.plugins.freeAccount['plugin-opts'] || '').split(';').map(i=>encodeURIComponent(i)).join(';')}#` : '';

let currentPassword = '';
let updateTime = Date.now();
Expand Down Expand Up @@ -173,7 +174,7 @@ const checkPort = async () => {
await manager.send({ command: 'add', port: randomPort(), password: randomPassword() });
await setKey('create', { time: Date.now() });
await setKey('flow', { flow: 0 });
qrcode = 'ss://' + Buffer.from(`${ method }:${ currentPassword }@${ address }:${ currentPort }`).toString('base64');
qrcode = 'ss://' + Buffer.from(`${ method }:${ currentPassword }`).toString('base64') + `@${ address }:${ currentPort }${ plugin }`;
}
}
};
Expand Down Expand Up @@ -214,7 +215,7 @@ if(config.plugins.freeAccount.ad) {

app.get('/', (req, res) => {
logger.info(`[${ req.ip }] /`);
qrcode = 'ss://' + Buffer.from(`${ method }:${ currentPassword }@${ address }:${ currentPort }`).toString('base64');
qrcode = 'ss://' + Buffer.from(`${ method }:${ currentPassword }`).toString('base64') + `@${ address }:${ currentPort }${ plugin }`;
return res.render('index', {
recaptcha: config.plugins.freeAccount.recaptcha ? config.plugins.freeAccount.recaptcha.site : '',
analytics,
Expand Down
16 changes: 15 additions & 1 deletion plugins/freeAccount/views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@
<div class="row">
<div class="address col-md-12 col-lg-12"></div>
</div>
<div class="row">
<div class="qrcode col-md-12 col-lg-12">
软件下载:
<a href="https://github.com/shadowsocks/ShadowsocksX-NG/releases">macOS</a>
|
<a href="https://github.com/shadowsocks/shadowsocks-windows/releases">Windows</a>
|
<a href="https://github.com/shadowsocks/shadowsocks-qt5/releases">Linux GUI</a>
|
<a href="https://github.com/shadowsocks/shadowsocks-libev/releases">Linux CLI</a>
|
<a href="https://github.com/shadowsocks/shadowsocks-android/releases">Android</a>
</div>
</div>
<script>
var i = 0;
var getToken = function() {
Expand All @@ -77,7 +91,7 @@
}, function(data) {
window.ssqrcode = data.qrcode;
window.ssscore = data.score;
var qr = qrcode(8, 'Q');
var qr = qrcode(8, 'M');
qr.addData(window.ssqrcode);
qr.make();
document.getElementById('qrcode').innerHTML = qr.createImgTag(6);
Expand Down