Commit 6754a9e8 authored by nanahira's avatar nanahira

tun proxy

parent 0f404acf
...@@ -51,6 +51,7 @@ interface Gateway { ...@@ -51,6 +51,7 @@ interface Gateway {
hidden: boolean; hidden: boolean;
badUdp: boolean; badUdp: boolean;
redirectAllPorts: boolean; redirectAllPorts: boolean;
tunProxy: string;
} }
class InventoryBuilder { class InventoryBuilder {
...@@ -149,7 +150,7 @@ class InventoryBuilder { ...@@ -149,7 +150,7 @@ class InventoryBuilder {
gateway.selectionMark = 0; gateway.selectionMark = 0;
gateway.redirectServerPort = 60100; gateway.redirectServerPort = 60100;
} }
gateway.redirectTargetPorts = gateway.redirectAllPorts ? '1:65535' : this.vars.redirectTargetPorts.replace(/-/g, ':'); gateway.redirectTargetPorts = (gateway.redirectAllPorts || gateway.tunProxy) ? '1:65535' : this.vars.redirectTargetPorts.replace(/-/g, ':');
gateway.pccRules = []; gateway.pccRules = [];
} }
return gateways; return gateways;
...@@ -314,11 +315,14 @@ class InventoryBuilder { ...@@ -314,11 +315,14 @@ class InventoryBuilder {
const gostConfig: GostConfig = { const gostConfig: GostConfig = {
Routes: availableGateways.map(gateway => { Routes: availableGateways.map(gateway => {
const useWarp = host.arch !== 'arm' && gateway.warp; let tunProxy: string = gateway.tunProxy;
if (gateway.tunProxy === 'warp') {
tunProxy = `http://localhost:${gateway.redirectServerPort - 2000}`;
}
return { return {
ServeNodes: [`red://${host.address}:${gateway.redirectServerPort}`], ServeNodes: [`red://${host.address}:${gateway.redirectServerPort}`],
Mark: useWarp ? 0 : gateway.selectionMark as number, Mark: tunProxy?.includes('localhost') ? 0 : gateway.selectionMark as number,
ChainNodes: useWarp ? [`http://localhost:${gateway.redirectServerPort - 2000}`] : undefined ChainNodes: tunProxy ? tunProxy.split('|') : undefined
} }
}) })
}; };
...@@ -336,7 +340,7 @@ class InventoryBuilder { ...@@ -336,7 +340,7 @@ class InventoryBuilder {
command: '-C /etc/gost/gost.json' command: '-C /etc/gost/gost.json'
}; };
if (host.arch !== 'arm') { if (host.arch !== 'arm') {
for (const gateway of availableGateways.filter(gw => gw.warp)) { for (const gateway of availableGateways.filter(gw => gw.tunProxy === 'warp')) {
host.dockerServices.services[`warp-${gateway.isp}`] = { host.dockerServices.services[`warp-${gateway.isp}`] = {
restart: 'always', restart: 'always',
image: 'git-registry.mycard.moe/nanahira/warp-proxy', image: 'git-registry.mycard.moe/nanahira/warp-proxy',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment