-
-
Save neopunisher/883dd38b7c869c2da96510be57623e41 to your computer and use it in GitHub Desktop.
// Im doing this "standalone" from the js console in an about:blank page | |
const tsconn = await import('https://cdn.jsdelivr.net/npm/@tailscale/connect@1.33.0-t2be951a58/pkg.js') | |
const wasmURL = 'https://cdn.jsdelivr.net/npm/@tailscale/connect@1.33.0-t2be951a58/main.wasm' | |
const ipn = await tsconn.createIPN({wasmURL}) | |
ipn.run({ | |
notifyState: (state)=>console.log('notifyState:', state), | |
notifyNetMap: (netMap)=>console.log('notifyNetMap:', netMap), | |
notifyBrowseToURL: (url)=>console.log('notifyBrowseToURL:', url), | |
notifyPanicRecover: (err)=>console.log('notifyPanicRecover:', url), | |
}) | |
// manually login | |
ipn.login() | |
// I can ping my tailscale ip and see icmp packets in the console. | |
// First i wanted to see if i could break cors before I handle accepting the connection and returnign html | |
// after login I try and test a GET request but it fails | |
// (i think in some other go lib code here https://github.com/tailscale/tailscale/blob/main/cmd/tsconnect/wasm/wasm_js.go#L487 but i dont know go well enough to go further) | |
const req = await ipn.fetch("https://www.twitter.com") | |
// Uncaught Get "https://www.twitter.com": lookup www.twitter.com: Protocol not available | |
// My plan is to make my own changes to https://github.com/tailscale/tailscale/blob/main/cmd/tsconnect/wasm/wasm_js.go | |
// to allow it to do the funnel stuff im assuming is elsewhere in the repo then issue a pull request | |
// - @CarterCole | |
// Thanks! |
I also would like to make the fetch able to do post requests and everything the native fetch does but thats a different can of worms
Author of the @tailscale/connect package here.
The fetch
function is definitely speculative, but when I added it (tailscale/tailscale@adc5ffe) the main way I tested it was to have it fetch other resources from the Tailnet via the PeerAPI. Can you and see if that still works?
The easiest way to get a PeerAPI endpoint is to use tailscale ping -peerapi <node name>
-- that will output an HTTP URL with (a port number) that you can then fetch from anywhere that's Tailscale-enabled (native or web client).
The easiest way to get a PeerAPI endpoint is to use
tailscale ping -peerapi <node name>
-- that will output an HTTP URL with (a port number) that you can then fetch from anywhere that's Tailscale-enabled (native or web client).
Thanks alot for your quick response... that does work... its not doing dns resolution but thats not the worst because i can probably DOH for now
im on the track now but it is gonna take so go changes... im trying to think of the api to implement... for now im gonna do something like the http api in node and make a lambda that takes a request header and body and returns a response. figuring out websockets is next
i also am gonna try and tell the control server im a funnel
Thanks for testing things out. I’m leaving for a two week vacation, but I’ll look into DNS when I’m back in January.
I do recall seeing something about dns being disabled. https://webvm.io/ is able to resolve domain names so I dont think its related but perhaps they are instantiating it differently than I am. I have an exit node so I dotn think its that