mirror of
https://github.com/go-gost/gost-ui.git
synced 2024-08-11 17:53:29 +00:00
优化模板
This commit is contained in:
@@ -13,8 +13,8 @@ const Chains: React.FC = () => {
|
||||
const [json, setJson] = useState<any>(null);
|
||||
const [config, setConfig] = useState("");
|
||||
const ts = useMemo(() => {
|
||||
return templates['chains']
|
||||
}, [])
|
||||
return templates["chains"];
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (json) {
|
||||
@@ -65,12 +65,15 @@ const Chains: React.FC = () => {
|
||||
const _nodes = nodes.map((node) => {
|
||||
const {
|
||||
addr,
|
||||
connector: { type: connectorType },
|
||||
connector: { type: connectorType, auth },
|
||||
dialer: { type: dialerType },
|
||||
} = node;
|
||||
const _auth = auth
|
||||
? auth.username + ":" + auth.password + "@"
|
||||
: "";
|
||||
return `${connectorType}${
|
||||
dialerType ? "+" + dialerType : ""
|
||||
}://${addr}`;
|
||||
}://${_auth}${addr}`;
|
||||
});
|
||||
return _nodes.join(",");
|
||||
});
|
||||
|
||||
@@ -71,8 +71,12 @@ const Services: React.FC = () => {
|
||||
const metadata = handler.metadata
|
||||
? qs.stringify(handler.metadata)
|
||||
: "";
|
||||
// const targets = forwarder // TODO:
|
||||
return `${xy}://${auth}${addr}${metadata ? "?" + metadata : ""}`;
|
||||
const targets =
|
||||
forwarder?.nodes.map((item) => item.addr).join(",") || "";
|
||||
|
||||
return `${xy}://${auth}${addr}${targets ? "/" + targets : ""}${
|
||||
metadata ? "?" + metadata : ""
|
||||
}`;
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -170,7 +174,7 @@ const Services: React.FC = () => {
|
||||
rename = true;
|
||||
}
|
||||
await addService(JSON.stringify({ ...json, name: addName }));
|
||||
rename && message.info(`己自动处理 name 为 "${addName}"`);
|
||||
rename && message.info(`name 已自动处理为 "${addName}"`);
|
||||
return true;
|
||||
}}
|
||||
></JsonForm>
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
export default [
|
||||
{
|
||||
name: "代理转发",
|
||||
cli: `gost -L socks5://:1080 -F socks5+tlc://username:password@100.100.100.100:1080`,
|
||||
themelate: `
|
||||
{
|
||||
"services": [
|
||||
{
|
||||
"name": "service-0",
|
||||
"addr": ":1080",
|
||||
"handler": {
|
||||
"type": "socks5",
|
||||
"chain": "chain-0"
|
||||
},
|
||||
"listener": {
|
||||
"type": "tcp"
|
||||
}
|
||||
}
|
||||
],
|
||||
"chains": [
|
||||
{
|
||||
"name": "chain-0",
|
||||
"hops": [
|
||||
{
|
||||
"name": "hop-0",
|
||||
"nodes": [
|
||||
{
|
||||
"name": "node-0",
|
||||
"addr": "100.100.100.100:1080",
|
||||
"connector": {
|
||||
"type": "socks5",
|
||||
"auth": {
|
||||
"username": "username",
|
||||
"password": "password"
|
||||
}
|
||||
},
|
||||
"dialer": {
|
||||
"type": "tcp",
|
||||
"tls": {
|
||||
"serverName": "100.100.100.100"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
`,
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,8 @@
|
||||
import { Select } from "antd"
|
||||
|
||||
|
||||
const Quicksetup:React.FC = ()=>{
|
||||
return <Select>
|
||||
|
||||
</Select>
|
||||
}
|
||||
@@ -33,6 +33,7 @@ export default {
|
||||
label: "http",
|
||||
json: `
|
||||
{
|
||||
"name": "service-0",
|
||||
"addr": ":1080",
|
||||
"handler": {
|
||||
"type": "http",
|
||||
@@ -50,6 +51,7 @@ export default {
|
||||
label: "https",
|
||||
json: `
|
||||
{
|
||||
"name": "service-0",
|
||||
"addr": ":1080",
|
||||
"handler": {
|
||||
"type": "http",
|
||||
@@ -131,6 +133,41 @@ export default {
|
||||
}`,
|
||||
},
|
||||
],
|
||||
chains: [
|
||||
{
|
||||
label: "典型转发",
|
||||
cli: "",
|
||||
json: `
|
||||
{
|
||||
"name": "chain-0",
|
||||
"hops": [
|
||||
{
|
||||
"name": "hop-0",
|
||||
"nodes": [
|
||||
{
|
||||
"name": "node-0",
|
||||
"addr": "proxy.xxx.com:1080",
|
||||
"connector": {
|
||||
"type": "socks5",
|
||||
"auth": {
|
||||
"username": "username",
|
||||
"password": "password"
|
||||
}
|
||||
},
|
||||
"dialer": {
|
||||
"type": "tcp",
|
||||
"tls": {
|
||||
"serverName": "proxy.xxx.com"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
`
|
||||
}
|
||||
],
|
||||
authers: [
|
||||
{
|
||||
label: "默认模板",
|
||||
|
||||
Reference in New Issue
Block a user