update tun/

This commit is contained in:
Yuri Iozzelli 2022-12-14 16:37:04 +01:00
parent 05dd3a8308
commit 9af6bbaa1f
5 changed files with 14 additions and 13 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

BIN
tun/tailscale.wasm Executable file → Normal file

Binary file not shown.

View File

@ -51,7 +51,7 @@ export async function init() {
IpStack.input(ev.data) IpStack.input(ev.data)
}; };
IpStack.output(function(p){ IpStack.output(function(p){
ipn.tun.postMessage(p); ipn.tun.postMessage(p, [p.buffer]);
}); });
}; };
setupIpStack(); setupIpStack();
@ -65,10 +65,15 @@ export async function init() {
if (localIp != newLocalIp) if (localIp != newLocalIp)
{ {
localIp = newLocalIp; localIp = newLocalIp;
IpStack.up({localIp, ipMap: { try{
IpStack.up({localIp, dnsIp, ipMap: {
["127.0.0.53"]: dnsIp, ["127.0.0.53"]: dnsIp,
[dnsIp]: "127.0.0.53", [dnsIp]: "127.0.0.53",
}}); }});
}catch(e){
console.log(e);
debugger;
}
} }
}, },
notifyBrowseToURL: (l) => listeners.onloginurl(l), notifyBrowseToURL: (l) => listeners.onloginurl(l),
@ -82,6 +87,7 @@ export async function init() {
listen: IpStack.listen, listen: IpStack.listen,
bind: IpStack.bind, bind: IpStack.bind,
parseIP: IpStack.parseIP, parseIP: IpStack.parseIP,
resolve: IpStack.resolve,
up: async (conf) => { up: async (conf) => {
if (ipn == null) { if (ipn == null) {
await lazyRunIpn(); await lazyRunIpn();

View File

@ -1,17 +1,11 @@
import {State, init} from "./tailscale_tun.js"; import {State, init} from "./tailscale_tun.js";
export async function autoConf({loginUrlCb, stateUpdateCb, netmapUpdateCb}) { export async function autoConf({loginUrlCb, stateUpdateCb, netmapUpdateCb, controlUrl, authKey}) {
const { listen, connect, bind, parseIP, up, down, login, logout, listeners } = await init(); const { listen, connect, bind, parseIP, resolve, up, down, login, logout, listeners } = await init();
const getSettings = () => {
settings.controlUrl = null;
settings.exitNodeIp = null;
settings.dnsIp = null;
settings.wantsRunning = true;
};
const settings = { const settings = {
controlUrl: undefined, controlUrl: controlUrl,
authKey: authKey,
exitNodeIp: undefined, exitNodeIp: undefined,
dnsIp: undefined, dnsIp: undefined,
wantsRunning: true, wantsRunning: true,
@ -75,6 +69,7 @@ export async function autoConf({loginUrlCb, stateUpdateCb, netmapUpdateCb}) {
connect, connect,
listen, listen,
parseIP, parseIP,
resolve,
up: async () => { up: async () => {
await up(settings); await up(settings);
}, },