ADSL拨号代理

终端操作

  • 购买动态拨号VPS主机(Centos 7.1)

  • SSH连接服务器

    • ssh 用户名@IP -p 端口
    • 例如:
      ssh root@127.170.65.214 -p 20063
  • 开始拨号

    • adsl -start
  • 停止拨号

    • adsl -stop
  • 远程服务器上安装TinyProxy

    • yum install -y epel -release
      yum update -y
      yum install -y tinyproxy
  • 配置TinyProxy

    • Port 8888,端口默认8888
    • Allow 127.0.0.1,表示允许连接的主机
    • # Allow 127.0.0.1,表示允许所有主机连接
    • 重启TinyProxy
      • systemctl enable tinyproxy.service
        systemctl restart tinyproxy.service
    • 关闭防火墙
      • systemctl stop firewalld.service
    • 验证TinyProxy
      • curl -x 拨号后的IP:端口 httpbin.org/get
        例如curl -x 119.0.1.234:8888 httpbin.org/get

Python操作

  • 初始数据

    # 拨号间隔
    ADSL_CYCLE = 100
    
    # 拨号出错重试间隔
    ADSL_ERROR_CYCLE = 5
    
    # ADSL命令
    ADSL_BASH = 'adsl-stop;adsl-start'
    
    # 代理运行端口
    PROXY_PORT = 8888
    
    # 客户端唯一标识
    CLIENT_NAME = 'adsl1'
    
    # 拨号网卡
    ADSL_IFNAME = 'ppp0'
    
    # Redis数据库IP
    REDIS_HOST = 'localhost'
    
    # Redis数据库密码, 如无则填None
    REDIS_PASSWORD = 'foobared'
    
    # Redis数据库端口
    REDIS_PORT = 6379
    
    # 代理池键名
    PROXY_KEY = 'adsl'
    
    # 测试URL
    TEST_URL = 'http://www.baidu.com'
    
    # 测试超时时间
    TEST_TIMEOUT = 20
    
    # API端口
    API_PORT = 8000
    adslproxy.config
原文地址:https://www.cnblogs.com/liyihua/p/11324832.html