ilteoood / docker-surfshark

Docker container with OpenVPN client preconfigured for SurfShark
MIT License
129 stars 33 forks source link

Sock5 Fails #82

Closed josearodrigueze closed 5 months ago

josearodrigueze commented 6 months ago

Hello, I tried to activate the socks5 service but it doesn't work. For now I want to activate this locally so that I can test connecting other services to it and then go to a server in the cloud. This is my configuration:

version: "3"

services: 
  vpn:
    image: ilteoood/docker-surfshark
    container_name: vpn
    # platform: linux/amd64
    environment: 
      - SURFSHARK_USER= YOUR_SURFSHARK_USER
      - SURFSHARK_PASSWORD= YOUR_SURFSHARK_PASS
      - SURFSHARK_COUNTRY=it
      - SURFSHARK_CITY=mil
      - CONNECTION_TYPE=udp
      - LAN_NETWORK=192.168.0.0/24
    cap_add: 
      - NET_ADMIN 
    devices:
      - /dev/net/tun
    ports:
      - 1080:1080 #if you want to use the socks5 server
    restart: unless-stopped
    dns:
      - 1.1.1.1

When I run curl -v --socks5 127.0.0.1:1081 http://myexternalip.com/raw

It doesn't work and the result is:

❯ curl -s -v --socks5 127.0.0.1:1080 http://myexternalip.com/raw
*   Trying 127.0.0.1:1080...
* Connected to 127.0.0.1 (127.0.0.1) port 1080
* Recv failure: Connection reset by peer
* SOCKS4: Failed receiving initial SOCKS5 response: Failure when receiving data from the peer
* Closing connection

I followed this other issue but it didn't work for me.

logs for the running container: image

I hope you can help me Thank you

ilteoood commented 6 months ago

What is the local ip of the device you are using?

josearodrigueze commented 6 months ago

Thanks for helping!

❯ curl -s https://httpbin.org/ip
{
  "origin": "181.43.201.201"
}

Netwotk Info image

ilteoood commented 6 months ago

Instead of 192.168.0.0/24 try to use 192.168.100.0/24

josearodrigueze commented 6 months ago

I changed it like you told me but it didn't work

image

❯ curl -v --socks5 localhost:1080 http://myexternalip.com/raw
*   Trying [::1]:1080...
* Connected to localhost (::1) port 1080
* Recv failure: Connection reset by peer
* SOCKS4: Failed receiving initial SOCKS5 response: Failure when receiving data from the peer
* Closing connection
curl: (97) Recv failure: Connection reset by peer
❯ curl -v --socks5 127.0.0.1:1080 http://myexternalip.com/raw
*   Trying 127.0.0.1:1080...
* Connected to 127.0.0.1 (127.0.0.1) port 1080
* Recv failure: Connection reset by peer
* SOCKS4: Failed receiving initial SOCKS5 response: Failure when receiving data from the peer
* Closing connection
curl: (97) Recv failure: Connection reset by peer
josearodrigueze commented 6 months ago
❯ sudo lsof -i -P | grep LISTEN | grep :1080
Password:
com.docke  6669  macbook  159u  IPv6 0x9d8aadfc9eafba13      0t0    TCP *:1080 (LISTEN)
ilteoood commented 6 months ago

Any notable log on the container side? Like, are you sure that it is effectively connected to surfshark?

josearodrigueze commented 6 months ago

This is the log for that execution!

image

Even to rule out that it was something in the connection with surfshark, I entered contend via docker exec, and ran a curl and it gave me a different IP than the host.

josearodrigueze commented 6 months ago

Check and inside the container port 1080 is being listened to. image

I even did a curl --socks5 172.27.0.2:1080 https://ifcfg.co inside the same container and it works.

but the thing is when you try to do that curl from the host, it keeps failing.

ilteoood commented 6 months ago

Try changing a piece of your configuration with the following:

ports:
      - 127.0.0.1:1080:1080
      - 127.0.0.1:1080:1080/udp
josearodrigueze commented 5 months ago

With this last configuration it works very well, I did notice that there are some sites that do not like to receive sock5 connections, but I think that is another topic.

Anyway, thank you very much