npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@remoon.net/xhe-link

v0.1.0

Published

ReverseProxy browser fetch api to xhe wireguard vpn network

Downloads

10

Readme

Introduction

ReverseProxy browser fetch api to xhe wireguard vpn network

How to use

you can see link_test.js and testdata/index.html

the real example by use UserScript

before connect browser and linux, we need generate key1, pubkey1(hex) and key2, pubkey2(hex)

echo -n 'key1: ' > /tmp/key1.txt; wg genkey >> /tmp/key1.txt
echo -n 'key2: ' > /tmp/key2.txt; wg genkey >> /tmp/key2.txt
echo -n 'pubkey1: ' > /tmp/pubkey1.txt; tail -c +7 /tmp/key1.txt | wg pubkey | base64 -d | xxd -p -c 32 >> /tmp/pubkey1.txt
echo -n 'pubkey2: ' > /tmp/pubkey2.txt; tail -c +7 /tmp/key2.txt | wg pubkey | base64 -d | xxd -p -c 32 >> /tmp/pubkey2.txt
cat /tmp/key1.txt /tmp/pubkey1.txt /tmp/key2.txt /tmp/pubkey2.txt | tee xhe-link-keys.txt
# open xhe-link-keys.txt, the below steps will use those keys

twitter has enable csp, it will reject any script soruce is not from twitter. so we need disable csp to allow UserScript execute, by use extenstion like CSP Unblock

// ==UserScript==
// @name        twitter spider - Xhe Link
// @namespace   Violentmonkey Scripts
// @match       *://twitter.com/*
// @version     1.0
// @author      -
// @require     https://unpkg.com/@remoon.net/[email protected]/dist/xhe-link.umd.js
// @run-at      document-start
// @description 02/06/2023, 02:52:30
// @grant none
// ==/UserScript==

// twitter service worker also enable csp, so disable sw is required
navigator.serviceWorker.register = (...args) => {
  console.log("sw: try regsiter", args);
  return new Promise((rl, rj) => {
    rj("disable sw");
  });
};

XheLinkLib.Init()
  .then(async () => {
    const xwg = await XheLink({
      log_level: "debug",
      private_key: "{key1}",
      links: ["https://xhe.remoon.net"],
      peers: ["peer://{pubkey2}"],
    });

    const server = await xwg.ListenTCP(80);
    server.Serve().catch((err) => {
      console.err(err);
    });

    let fetch = globalThis.fetch;
    globalThis.fetch = async function hookedFetch(u, init = {}) {
      if (init.credentials === "include") {
        let h = new Headers(init?.headers);
        let csrf = await cookieStore.get("ct0").then((c) => c.value);
        h.set("x-csrf-token", csrf);
        init.headers = h;
      }
      return fetch(u, init).then((res) => {
        let u = new URL(res.url);
        let hostname = u.hostname;
        if (hostname.endsWith("twitter.com")) {
          let rh = new Headers(res.headers);
          // twitter api response content-length header is not equal the real content body length
          rh.delete("content-length");
          return new Response(res.body, {
            headers: rh,
            status: res.status,
            statusText: res.statusText,
          });
        }
        return res;
      });
    };

    await server.ReverseProxy("/", "https://twitter.com");

    console.log("reverse proxy successful");
  })
  .catch((err) => console.error(err));

get xhe from https://github.com/remoon-net/xhe

xhe --vtun --export 10808 \
  -k {key2} \
  -p 'https://xhe.remoon.net?peer={pubkey1}&keepalive=15' \
  --log debug

# another shell
curl -x socks5://127.0.0.1:10808 \
  -H 'authorization: Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA' \
  -H 'js.fetch.credentials: include' \
  'http://twitter.com/i/api/graphql/_pnlqeTOtnpbIL9o-fS_pg/ProfileSpotlightsQuery?variables=%7B%22screen_name%22%3A%22shynome%22%7D' \
  --resolve twitter.com:80:$(xhe ip {pubkey1})