Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ASK] How to Encrypt Payload from ss-local to ss-remote? #1286

Open
kicut opened this issue Sep 3, 2023 · 0 comments
Open

[ASK] How to Encrypt Payload from ss-local to ss-remote? #1286

kicut opened this issue Sep 3, 2023 · 0 comments

Comments

@kicut
Copy link

kicut commented Sep 3, 2023

First of all, sorry, this question might be a bit deviating from this repository, I'm asking for help here because I see this repository is quite active among the others.

So, recently I just got into network programming. I want to know how to encrypt data sent from ss-local to ss-remote.

image

I've been reading the documentation and diving into some ss-local tool libraries in the wild for a few days, but I don't get the answer it's still too abstract for me. I have tried it on Nodejs but I am stuck on this error, error message from Shadowsocks Go Server.

2023/09/03 20:56:57 tcp.go:126: failed to get target address from 127.0.0.1:36654: cipher: message authentication failed

Can someone please provide an example of how to send data from ss-local to ss-remote in Node.js, the following code below might work as a starting sample.

import net from "net";

const ssServer = {
  host: "127.0.0.1",
  password: "password",
  port: 8488,
  encryption: {
    method: "aes-256-gcm",
    keySize: 32,
    ivLen: 16,
    saltSize: 32,
    nonceSize: 12,
    tagSize: 16,
  },
};

const streamToServer = net.createConnection({
  host: ssServer.host,
  port: ssServer.port,
});

streamToServer.on("ready", () => {
  const data = Buffer.from("GET / HTTP/1.1\r\nHost: ifconfig.me\r\n\r\n");
  // ?????????????????????????????????????
  streamToServer.write(data);
});

streamToServer.on("data", (data) => {
  console.log("on data,", data);
});

streamToServer.on("connect", () => {
  console.log("connected");
});

streamToServer.on("error", (e) => {
  console.log("error", e);
});

I really appreciate any answer, thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant