Skip to content

Commit

Permalink
feat: add sing-box.json template for sing-box support
Browse files Browse the repository at this point in the history
  • Loading branch information
geekdada committed May 3, 2024
1 parent d23f9d2 commit 9d4b5e6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
32 changes: 29 additions & 3 deletions template/surgio.conf.js.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
'use strict';

const { utils } = require('surgio');
const { utils, extendOutbounds } = require('surgio');

/**
* 使用文档:https://surgio.js.org/
Expand Down Expand Up @@ -103,6 +101,34 @@ module.exports = {
magicVariable: utils.hkFilter,
},
},

/**
* sing-box
*/
{
name: 'sing-box.json',
template: 'sing-box',
templateType: 'json',
extendTemplate: extendOutbounds(
({ getSingboxNodes, getSingboxNodeNames, proxyTestUrl, nodeList }) => [
{
type: 'selector',
tag: 'proxy',
outbounds: ['auto', ...getSingboxNodeNames(nodeList)],
interrupt_exist_connections: false,
},
{
type: 'urltest',
tag: 'auto',
outbounds: getSingboxNodeNames(nodeList),
url: proxyTestUrl,
interrupt_exist_connections: false,
},
...getSingboxNodes(nodeList),
],
),
provider: 'demo',
},
],
/**
* 订阅地址的前缀部分,以 / 结尾
Expand Down
14 changes: 0 additions & 14 deletions template/template/singbox.tpl → template/template/sing-box.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,6 @@
}
],
"outbounds": [
{
"type": "selector",
"tag": "proxy",
"outbounds": {{ getSingboxNodeNames(nodeList, null, ['auto']) | json }},
"interrupt_exist_connections": false
},
{
"type": "urltest",
"tag": "auto",
"outbounds": {{ getSingboxNodeNames(nodeList) | json }},
"url": "{{ proxyTestUrl }}",
"interrupt_exist_connections": false
},
{{ getSingboxNodesString(nodeList) }},
{
"type": "direct",
"tag": "direct",
Expand Down

0 comments on commit 9d4b5e6

Please sign in to comment.