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

unsupported encryption method: chacha20-ietf-poly1305 #6

Open
talentlessguy opened this issue Nov 4, 2024 · 10 comments
Open

unsupported encryption method: chacha20-ietf-poly1305 #6

talentlessguy opened this issue Nov 4, 2024 · 10 comments

Comments

@talentlessguy
Copy link

This fails to create a new dialer:

dialer, err := shadowsocks.NewDialer("ss://Y2hhY2hhMjAtaWV0Zi1wb2x5MTMwNTp1OTE4OXJ3dXEzMzgwODJ0OTc=@1.1.1.1:1321")
if err != nil {
	fmt.Println("Error creating Shadowsocks dialer:", err)
	return
}

yields

Error creating Shadowsocks dialer: unsupported encryption method: chacha20-ietf-poly1305

what's the issue? the library claims to support chacha20-ietf-poly1305

@wzshiming
Copy link
Owner

wzshiming commented Nov 5, 2024

It seem you didn't register it, add this to your main package

import _ "github.com/wzshiming/shadowsocks/init"

@talentlessguy
Copy link
Author

it worked, thanks!

@talentlessguy
Copy link
Author

talentlessguy commented Nov 5, 2024

it seems to throw another error now:

chacha20poly1305: message authentication failed

despite the configuration itself working (tested via sslocal)

here's the full code:

	serverAddress := "ss://Y2hhY2hhMjAtaWV0Zi1wb2x5MTMwNTp1OTE4OXJ3dXEzMzgwODJ0OTc=@1.1.1.1:1321"

		// Create a new Shadowsocks dialer
		dialer, err := shadowsocks.NewDialer(serverAddress)
		if err != nil {
			fmt.Println("Error creating Shadowsocks dialer:", err)
			continue
		}

		// Create an HTTP client using the Shadowsocks dialer
		transport := &http.Transport{
			Dial: dialer.Dial,
		}
		client := &http.Client{Transport: transport}

		// Make a request to ifconfig.me
		resp, err := client.Get("https://ifconfig.me")
		if err != nil {
			fmt.Printf("\n%d: Error making request:", user.Port)
			fmt.Println(err)
			continue
		}
		defer resp.Body.Close()

		// Read and print the response body
		body, err := io.ReadAll(resp.Body)
		if err != nil {
			fmt.Printf("\n%d: Error reading response body:", user.Port)
			fmt.Println(err)
		}
		if body != nil {
			fmt.Printf("Success: \n%d: %s", user.Port, body)
		}

@talentlessguy talentlessguy reopened this Nov 5, 2024
@wzshiming
Copy link
Owner

sslocal is a conversion of ss to socks5, if you are using ss you can connect directly to your ss server without sslocal, or use socks5 to connect to sslocal.

@talentlessguy
Copy link
Author

talentlessguy commented Nov 6, 2024

@wzshiming my final goal is verifying that the shadowsocks configuration is valid by doing a test request. I brought up sslocal demonstrating that the config is valid (I'm able to do the same request using curl --socks5), but the library fails to make the request.

Is it possible to connect to shadowsocks and then use it as a SOCKS5 proxy in the dialer directly? I think I'm misusing the dialer here

@wzshiming
Copy link
Owner

wzshiming commented Nov 7, 2024

This is a shadowsocks library, not socks5. may you need wzshiming/socks5 or wzshiming/bridge

@talentlessguy
Copy link
Author

@wzshiming okay then how would i connect both through shadowsocks and socks5 in a single go program?

@wzshiming
Copy link
Owner

I still don't understand what you're trying to do, but I'm guessing you're probably trying to have the effect of converting the ss service into a socks5 service for other processes in your local.

import (
	"github.com/wzshiming/shadowsocks"
	"github.com/wzshiming/socks5"
)

func main() {
	dialer, _ := shadowsocks.NewDialer("ss://your-ss-server")
	svc := &socks5.Server{
		ProxyDial: dialer.DialContext,
	}
	_ = svc.ListenAndServe("tcp", "127.0.0.1:1080")
}
https_proxy=socks5://127.0.0.1:1080 http_proxy=socks5://127.0.0.1:1080 curl -v https://example.org/

@talentlessguy
Copy link
Author

@wzshiming I'm writing a program to test if a shadowsocks connection is valid by making a test request

ideally the program would both connect to ShadowSocks and to a socks5 server created by a shadowsocks instance and then make a test request

@wzshiming
Copy link
Owner

Think of it as socks5, not shadowsocks, use socks5 to connect to your socks5 server

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

2 participants