| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- # PIA (Private Internet Access) SOCKS5 Proxy Configuration
- # Replace these values with your actual PIA credentials and preferred server
- # PIA SOCKS5 Proxy Server Details
- # You can find the full list of PIA SOCKS5 servers at:
- # https://www.privateinternetaccess.com/helpdesk/guides/desktop/linux/linux-openvpn-socks-proxy
- # Common PIA SOCKS5 servers:
- PROXY_ADDRESS = "proxy-nl.privateinternetaccess.com" # Netherlands server
- # PROXY_ADDRESS = "proxy-us-east.privateinternetaccess.com" # US East
- # PROXY_ADDRESS = "proxy-us-west.privateinternetaccess.com" # US West
- # PROXY_ADDRESS = "proxy-uk.privateinternetaccess.com" # UK
- # PROXY_ADDRESS = "proxy-de.privateinternetaccess.com" # Germany
- # PROXY_ADDRESS = "proxy-ca.privateinternetaccess.com" # Canada
- # PROXY_ADDRESS = "proxy-au.privateinternetaccess.com" # Australia
- PROXY_PORT = 1080 # Standard SOCKS5 port for PIA
- # Your PIA credentials
- # IMPORTANT: Replace these with your actual PIA username and password
- PROXY_USER = "x7652327" # Replace with your PIA username
- PROXY_PASS = "XEf6mg5zFK" # Replace with your PIA password
- # Alternative servers by region (uncomment and use as needed):
- SERVERS = {
- "netherlands": "proxy-nl.privateinternetaccess.com",
- "us_east": "proxy-us-east.privateinternetaccess.com",
- "us_west": "proxy-us-west.privateinternetaccess.com",
- "uk": "proxy-uk.privateinternetaccess.com",
- "germany": "proxy-de.privateinternetaccess.com",
- "canada": "proxy-ca.privateinternetaccess.com",
- "australia": "proxy-au.privateinternetaccess.com",
- "japan": "proxy-jp.privateinternetaccess.com",
- "singapore": "proxy-sg.privateinternetaccess.com"
- }
- def get_proxy_url():
- """Generate the complete SOCKS5 proxy URL with authentication."""
- if PROXY_USER and PROXY_PASS and PROXY_ADDRESS:
- return f"socks5://{PROXY_USER}:{PROXY_PASS}@{PROXY_ADDRESS}:{PROXY_PORT}"
- elif PROXY_ADDRESS:
- return f"socks5://{PROXY_ADDRESS}:{PROXY_PORT}"
- else:
- return None
- def get_proxy_info():
- """Get proxy configuration information."""
- return {
- "address": PROXY_ADDRESS,
- "port": PROXY_PORT,
- "username": PROXY_USER,
- "password": PROXY_PASS,
- "url": get_proxy_url()
- }
- # Test connectivity function
- def test_proxy_connectivity():
- """Test if the proxy configuration is working."""
- import subprocess
- import sys
-
- proxy_url = get_proxy_url()
- if not proxy_url:
- print("❌ No proxy configuration found")
- return False
-
- print(f"🧪 Testing PIA SOCKS5 proxy: {PROXY_ADDRESS}:{PROXY_PORT}")
- print(f"👤 Username: {PROXY_USER}")
-
- try:
- # Test with a simple curl command
- test_cmd = [
- "curl", "--socks5", f"{PROXY_USER}:{PROXY_PASS}@{PROXY_ADDRESS}:{PROXY_PORT}",
- "--connect-timeout", "10",
- "--max-time", "15",
- "https://ipinfo.io/ip"
- ]
-
- result = subprocess.run(test_cmd, capture_output=True, text=True, timeout=20)
-
- if result.returncode == 0:
- ip = result.stdout.strip()
- print(f"✅ Proxy is working! External IP: {ip}")
- return True
- else:
- print(f"❌ Proxy test failed: {result.stderr.strip()}")
- return False
-
- except subprocess.TimeoutExpired:
- print("⏰ Proxy test timed out")
- return False
- except FileNotFoundError:
- print("⚠️ curl not found, cannot test proxy connectivity")
- return False
- except Exception as e:
- print(f"💥 Error testing proxy: {e}")
- return False
- if __name__ == "__main__":
- print("PIA SOCKS5 Proxy Configuration")
- print("=" * 40)
-
- info = get_proxy_info()
- print(f"Address: {info['address']}")
- print(f"Port: {info['port']}")
- print(f"Username: {info['username']}")
- print(f"Password: {'*' * len(info['password']) if info['password'] else 'Not set'}")
- print(f"Full URL: {info['url']}")
-
- print("\n" + "=" * 40)
- test_proxy_connectivity()
|