Skip to content

SOCKS5 Proxy

SOCKS5 proxy provides broader protocol support, including TCP and UDP traffic, suitable for applications that require more low-level network control.

Basic Configuration

Proxy Address

Server: gtx.paopaous.net
Port: 38082

Authentication Format (k:v-k:v)

Username: myuser:password-ip:acpsres-c:US
Password: (leave empty or any value)

Usage Examples

Curl Command

bash
curl -x "socks5h://myuser:password-ip:acpsres-c:US@gtx.paopaous.net:38082" \
  -L https://httpbin.org/ip

Python Code

python
import requests
from bs4 import BeautifulSoup
import urllib3

# Disable SSL warnings (use with caution in production)
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

# SOCKS5 proxy configuration
proxy_host = "gtx.paopaous.net"
proxy_port = 38082
proxy_user = "myuser:password-ip:acpsres-c:US"

# Set SOCKS5 proxy
proxies = {
    "http": f"socks5://{proxy_user}@{proxy_host}:{proxy_port}",
    "https": f"socks5://{proxy_user}@{proxy_host}:{proxy_port}"
}

# Basic connection test
try:
    response = requests.get("https://httpbin.org/ip", proxies=proxies, verify=False)
    print(f"Status code: {response.status_code}")
    print(f"IP address: {response.json()}")
except Exception as e:
    print(f"Connection test failed: {e}")

# UDP support test (requires socks library)
try:
    import socks
    import socket
    
    # Configure SOCKS5 proxy
    socks.set_default_proxy(socks.SOCKS5, proxy_host, proxy_port, 
                            username=proxy_user.split(':')[0], 
                            password=proxy_user.split(':')[1])
    socket.socket = socks.socksocket
    
    print("SOCKS5 UDP configuration successful")
except ImportError:
    print("Need to install PySocks: pip install PySocks")
except Exception as e:
    print(f"UDP test failed: {e}")

# Web scraping test
try:
    response = requests.get("https://example.com", proxies=proxies, verify=False)
    print(f"Web scraping status code: {response.status_code}")
    
    if response.status_code == 200:
        soup = BeautifulSoup(response.content, 'html.parser')
        title = soup.find('title')
        if title:
            print(f"Page title: {title.get_text()}")
        print(f"Page content length: {len(response.text)}")
except Exception as e:
    print(f"Web scraping failed: {e}")

Node.js Code

javascript
const axios = require('axios');
const { SocksProxyAgent } = require('socks-proxy-agent');

// SOCKS5 proxy configuration
const proxyUrl = 'socks5://myuser:password-ip:acpsres-c:US@gtx.paopaous.net:38082';
const httpsAgent = new SocksProxyAgent(proxyUrl);

// Basic IP test
async function testIP() {
  try {
    const response = await axios.get('https://httpbin.org/ip', { httpsAgent });
    console.log(`Status code: ${response.status}`);
    console.log(`IP address: ${JSON.stringify(response.data)}`);
  } catch (error) {
    console.error(`IP test failed: ${error.message}`);
  }
}

// Web content fetching
async function fetchWebPage() {
  try {
    const response = await axios.get('https://example.com', { 
      httpsAgent,
      headers: {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
      }
    });
    console.log(`Status code: ${response.status}`);
    console.log(`Page title: ${response.data.match(/<title>(.*?)<\/title>/)?.[1] || 'Not found'}`);
    console.log(`Content length: ${response.data.length} characters`);
  } catch (error) {
    console.error(`Web page fetch failed: ${error.message}`);
  }
}

// DNS resolution test
async function testDNS() {
  try {
    const response = await axios.get('https://httpbin.org/dns', { 
      httpsAgent,
      params: { query: 'example.com' }
    });
    console.log(`DNS resolution: ${JSON.stringify(response.data)}`);
  } catch (error) {
    console.error(`DNS test failed: ${error.message}`);
  }
}

// Run all tests
async function runTests() {
  console.log('=== SOCKS5 Proxy Tests Started ===');
  await testIP();
  console.log('\n---');
  await fetchWebPage();
  console.log('\n---');
  await testDNS();
  console.log('\n=== Tests Completed ===');
}

runTests();

Parameter Details

Username Parameters (k:v-k:v format)

myuser:password-ip:acpsres-c:US
Key-Value PairDescriptionExampleRequired
myuser:passwordUsername and passwordjohn_doe:abc123
ip:acpsresProduct type identifierip:acpsres, ip:acpsstatic, ip:acpsdc
c:USCountry codec:US, c:UK, c:JP
id:12345Session IDid:any_string

SOCKS5 Features

DNS Resolution

SOCKS5 proxy supports remote DNS resolution, which can prevent DNS leaks:

python
import requests

proxies = {
    "http": "socks5h://myuser:password-ip:acpsres-c:US@gtx.paopaous.net:38082",
    "https": "socks5h://myuser:password-ip:acpsres-c:US@gtx.paopaous.net:38082"
}

# Use socks5h for remote DNS resolution
response = requests.get("https://httpbin.org/ip", proxies=proxies)
print(response.json())

UDP Support

SOCKS5 supports UDP traffic, suitable for DNS queries, video streaming, etc.:

python
import socks
import socket

# Configure SOCKS5 proxy for UDP
socks.set_default_proxy(socks.SOCKS5, "gtx.paopaous.net", 38082, 
                        username="myuser", password="password")
socket.socket = socks.socksocket

# UDP request example
import dns.resolver
resolver = dns.resolver.Resolver()
resolver.nameservers = ['8.8.8.8']
result = resolver.resolve('example.com', 'A')
for rdata in result:
    print(f"DNS result: {rdata}")

Application Scenarios

Database Connections

python
import psycopg2
import socks
import socket

# Configure SOCKS5 proxy
socks.set_default_proxy(socks.SOCKS5, "gtx.paopaous.net", 38082, 
                        username="myuser", password="password")
socket.socket = socks.socksocket

# Connect to database through proxy
conn = psycopg2.connect(
    host="your-db-host.com",
    database="your_db",
    user="db_user",
    password="db_password"
)

Email Sending

python
import smtplib
import socks
import socket

# Configure SOCKS5 proxy
socks.set_default_proxy(socks.SOCKS5, "gtx.paopaous.net", 38082, 
                        username="myuser", password="password")
socket.socket = socks.socksocket

# Send email through proxy
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login('your_email@gmail.com', 'your_password')
server.send_message(message)

FTP Connections

python
import ftplib
import socks
import socket

# Configure SOCKS5 proxy
socks.set_default_proxy(socks.SOCKS5, "gtx.paopaous.net", 38082, 
                        username="myuser", password="password")
socket.socket = socks.socksocket

# FTP connection through proxy
ftp = ftplib.FTP('ftp.example.com')
ftp.login('username', 'password')
ftp.retrlines('LIST')

Session Management

Session Persistence

bash
curl -x "socks5h://myuser:password-ip:acpsres-c:US-id:12345@gtx.paopaous.net:38082" \
  -L https://httpbin.org/ip

Session Parameters

  • id: Session identifier, maintains same IP for same session
  • Duration: Session persistence time (default: 10 minutes)

Error Handling

Authentication Failed

python
import requests

proxies = {
    "http": "socks5://wronguser:wrongpass-ip:acpsres-c:US@gtx.paopaous.net:38082",
    "https": "socks5://wronguser:wrongpass-ip:acpsres-c:US@gtx.paopaous.net:38082"
}

try:
    response = requests.get("https://httpbin.org/ip", proxies=proxies, timeout=10)
    print(response.json())
except requests.exceptions.ProxyError as e:
    print(f"Authentication failed: {e}")
except requests.exceptions.ConnectionError as e:
    print(f"Connection failed: {e}")

Connection Timeout

python
import requests

proxies = {
    "http": "socks5://myuser:password-ip:acpsres-c:US@gtx.paopaous.net:38082",
    "https": "socks5://myuser:password-ip:acpsres-c:US@gtx.paopaous.net:38082"
}

try:
    response = requests.get("https://httpbin.org/ip", 
                          proxies=proxies, 
                          timeout=30)
    print(response.json())
except requests.exceptions.Timeout:
    print("Request timeout, please try again")
except requests.exceptions.ConnectionError as e:
    print(f"Connection error: {e}")

Performance Optimization

Connection Pool

python
import requests
from requests.adapters import HTTPAdapter

session = requests.Session()
session.mount('http://', HTTPAdapter(max_retries=3, pool_connections=10))
session.mount('https://', HTTPAdapter(max_retries=3, pool_connections=10))

proxies = {
    "http": "socks5://myuser:password-ip:acpsres-c:US@gtx.paopaous.net:38082",
    "https": "socks5://myuser:password-ip:acpsres-c:US@gtx.paopaous.net:38082"
}

response = session.get("https://httpbin.org/ip", proxies=proxies)
print(response.json())

Concurrent Requests

python
import concurrent.futures
import requests

def fetch_socks5(url):
    proxies = {
        "http": "socks5://myuser:password-ip:acpsres-c:US@gtx.paopaous.net:38082",
        "https": "socks5://myuser:password-ip:acpsres-c:US@gtx.paopaous.net:38082"
    }
    return requests.get(url, proxies=proxies)

urls = ["https://httpbin.org/ip"] * 10

with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:
    futures = [executor.submit(fetch_socks5, url) for url in urls]
    for future in concurrent.futures.as_completed(futures):
        print(future.result().json())

Comparison with HTTP Proxy

FeatureHTTP ProxySOCKS5 Proxy
Protocol SupportHTTP/HTTPS onlyTCP/UDP, broader protocol support
DNS ResolutionLocal DNSRemote DNS (prevents leaks)
PerformanceSlightly fasterSlightly slower but more flexible
Use CasesWeb browsing, API callsDatabase, email, FTP, gaming
ConfigurationSimplerMore complex but powerful
const { SocksProxyAgent } = require('socks-proxy-agent');

// SOCKS5 proxy configuration const proxyUrl = 'socks5://myuser:ip:res-c:US:your_password_here@gtx.paopaous.net:38082'; const httpsAgent = new SocksProxyAgent(proxyUrl);

// Send request axios.get('https://httpbin.org/ip', { httpsAgent }) .then(response => console.log(response.data)) .catch(error => console.error(error));


## SOCKS5 vs HTTP Proxy

| Feature | HTTP Proxy | SOCKS5 Proxy |
|---------|------------|--------------|
| Protocol Support | HTTP/HTTPS | TCP/UDP |
| Performance | Faster | Slightly Slower |
| Compatibility | Better | Average |
| DNS Resolution | Client | Proxy Server |
| Use Cases | Web Browsing | Broader Applications |

## Advanced Configuration

### DNS Resolution Control

SOCKS5 proxy supports two DNS resolution methods:

#### Method 1: Client Resolution (socks5://)
```bash
curl -x "socks5://myuser:ip:res-c:US:your_password_here@gtx.paopaous.net:38082" \
  -L https://httpbin.org/ip

Method 2: Proxy Server Resolution (socks5h://)

bash
curl -x "socks5h://myuser:ip:res-c:US:your_password_here@gtx.paopaous.net:38082" \
  -L https://httpbin.org/ip

Recommend using socks5h:// to let the proxy server handle DNS resolution for better anonymity.

UDP Support

SOCKS5 supports UDP traffic, suitable for applications requiring UDP protocols:

python
import socket
import socks

# Configure SOCKS5 proxy
socks.set_default_proxy(socks.SOCKS5, "gtx.paopaous.net", 38082, 
                        username="myuser:ip:res-c:US", 
                        password="your_password_here")
socket.socket = socks.socksocket

# UDP communication example
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(b"Hello UDP", ("example.com", 53))

Application Scenarios

Database Connection

python
import psycopg2
import socks
import socket

# Configure SOCKS5 proxy
socks.set_default_proxy(socks.SOCKS5, "gtx.paopaous.net", 38082,
                        username="myuser:ip:res-c:US",
                        password="your_password_here")
socket.socket = socks.socksocket

# Database connection
conn = psycopg2.connect(
    host="your-db-host.com",
    database="your_db",
    user="db_user",
    password="db_password"
)

Email Sending

python
import smtplib
import socks
import socket

# Configure SOCKS5 proxy
socks.set_default_proxy(socks.SOCKS5, "gtx.paopaous.net", 38082,
                        username="myuser:ip:res-c:US",
                        password="your_password_here")
socket.socket = socks.socksocket

# Send email
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login('your_email@gmail.com', 'your_password')
server.send_message(message)
server.quit()

FTP Connection

python
import ftplib
import socks
import socket

# Configure SOCKS5 proxy
socks.set_default_proxy(socks.SOCKS5, "gtx.paopaous.net", 38082,
                        username="myuser:ip:res-c:US",
                        password="your_password_here")
socket.socket = socks.socksocket

# FTP connection
ftp = ftplib.FTP('ftp.example.com')
ftp.login('ftp_user', 'ftp_password')
ftp.retrlines('LIST')
ftp.quit()

Error Handling

Common Errors and Solutions

SOCKS5 Proxy Connection Failed

python
import requests
import socks
import socket

def test_socks5_proxy():
    try:
        proxies = {
            "http": "socks5://myuser:ip:res-c:US:your_password_here@gtx.paopaous.net:38082",
            "https": "socks5://myuser:ip:res-c:US:your_password_here@gtx.paopaous.net:38082"
        }
        
        response = requests.get("https://httpbin.org/ip", proxies=proxies, timeout=30)
        print("SOCKS5 proxy connection successful:", response.json())
        
    except requests.exceptions.ProxyError as e:
        print(f"Proxy connection error: {e}")
    except requests.exceptions.Timeout as e:
        print(f"Request timeout: {e}")
    except Exception as e:
        print(f"Other error: {e}")

test_socks5_proxy()

Authentication Failed

python
# Check authentication format
import requests

def test_authentication():
    # Test different authentication formats
    auth_formats = [
        "myuser:ip:res-c:US:your_password_here",
        "myuser:ip:res-c:US",
        "myuser:ip:res-c"
    ]
    
    for auth in auth_formats:
        try:
            proxies = {
                "http": f"socks5://{auth}@gtx.paopaous.net:38082",
                "https": f"socks5://{auth}@gtx.paopaous.net:38082"
            }
            
            response = requests.get("https://httpbin.org/ip", proxies=proxies, timeout=10)
            print(f"Authentication successful: {auth}")
            break
            
        except Exception as e:
            print(f"Authentication failed: {auth} - {e}")

test_authentication()

Performance Optimization

Connection Reuse

python
import requests
from requests.adapters import HTTPAdapter

session = requests.Session()

# Configure SOCKS5 proxy
proxies = {
    "http": "socks5://myuser:ip:res-c:US:your_password_here@gtx.paopaous.net:38082",
    "https": "socks5://myuser:ip:res-c:US:your_password_here@gtx.paopaous.net:38082"
}

# Configure connection pool
session.mount('http://', HTTPAdapter(max_retries=3, pool_connections=10))
session.mount('https://', HTTPAdapter(max_retries=3, pool_connections=10))

# Reuse connections
for i in range(5):
    response = session.get("https://httpbin.org/ip", proxies=proxies)
    print(f"Request {i+1}: {response.json()}")

Concurrency Control

python
import concurrent.futures
import requests
import time

def fetch_with_socks5(url, delay=0):
    time.sleep(delay)  # Avoid too frequent requests
    
    proxies = {
        "http": "socks5://myuser:ip:res-c:US:your_password_here@gtx.paopaous.net:38082",
        "https": "socks5://myuser:ip:res-c:US:your_password_here@gtx.paopaous.net:38082"
    }
    
    try:
        start_time = time.time()
        response = requests.get(url, proxies=proxies, timeout=30)
        end_time = time.time()
        
        return {
            'url': url,
            'success': True,
            'data': response.json(),
            'duration': end_time - start_time
        }
    except Exception as e:
        return {
            'url': url,
            'success': False,
            'error': str(e)
        }

# Concurrent requests
urls = ["https://httpbin.org/ip"] * 10

with concurrent.futures.ThreadPoolExecutor(max_workers=3) as executor:
    futures = [executor.submit(fetch_with_socks5, url, i*0.5) for i, url in enumerate(urls)]
    
    for future in concurrent.futures.as_completed(futures):
        result = future.result()
        if result['success']:
            print(f"Success: {result['url']} - Duration: {result['duration']:.2f}s")
        else:
            print(f"Failed: {result['url']} - Error: {result['error']}")

Best Practices

1. Use socks5h://

Recommend using socks5h:// instead of socks5:// to let the proxy server handle DNS resolution.

2. Set Reasonable Timeout

python
proxies = {
    "http": "socks5://myuser:ip:res-c:US:your_password_here@gtx.paopaous.net:38082",
    "https": "socks5://myuser:ip:res-c:US:your_password_here@gtx.paopaous.net:38082"
}

response = requests.get(url, proxies=proxies, timeout=(10, 30))  # Connection timeout 10s, read timeout 30s

3. Implement Retry Mechanism

python
import time
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry

session = requests.Session()

# Configure retry strategy
retry_strategy = Retry(
    total=3,
    backoff_factor=1,
    status_forcelist=[429, 500, 502, 503, 504]
)

adapter = HTTPAdapter(max_retries=retry_strategy)
session.mount("http://", adapter)
session.mount("https://", adapter)

proxies = {
    "http": "socks5://myuser:ip:res-c:US:your_password_here@gtx.paopaous.net:38082",
    "https": "socks5://myuser:ip:res-c:US:your_password_here@gtx.paopaous.net:38082"
}

response = session.get("https://httpbin.org/ip", proxies=proxies)

Next: Authentication

基于 MIT 许可发布