Open talentlessguy opened 3 weeks ago
It seem you didn't register it, add this to your main package
import _ "github.com/wzshiming/shadowsocks/init"
it worked, thanks!
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)
}
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.
@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
This is a shadowsocks library, not socks5. may you need wzshiming/socks5 or wzshiming/bridge
@wzshiming okay then how would i connect both through shadowsocks and socks5 in a single go program?
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/
@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
Think of it as socks5, not shadowsocks, use socks5 to connect to your socks5 server
This fails to create a new dialer:
yields
what's the issue? the library claims to support
chacha20-ietf-poly1305