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

View file

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