Giter VIP home page Giter VIP logo

proxy-collect's Introduction

proxy-collect - GO Proxy Collector

GO语言实现的ip代理池,隧道代理

图片

功能

  • 通过api获取可用代理ip列表
  • 隧道代理服务:支持开启多个端口监听,支持多协议,多级转发,用户名密码较验,用户限流
  • 支持redis或mysql作为存储
  • 自动抓取互联网上的免费代理ip
  • 定时检测ip可用性,失效ip复检、记录ip存活时间
  • 获取ip归属地等信息
  • 配置代理超时时间

使用方法:

安装

git clone https://github.com/tongsq/proxy-collect.git
cd proxy-collect

启动服务

1、启动脚本收集免费代理ip

go run ./cmd -S=job -C=conf.yaml

2、启动api服务

go run ./cmd -S=api -C=conf.yaml

3、启动隧道代理服务

go run ./cmd -S=tunnel -C=conf.yaml

通过接口获取可用ip

curl 127.0.0.1:8090/all?city=上海&duration=100

启动多个服务

go run ./cmd -S=job -S=api -C=conf.yaml

一键启动

go run ./cmd -S=all -C=conf.yaml

yaml配置

设置存储媒介

A、数据存储到redis

  • 修改配置文件conf.yaml如下
    dao: redis
    redis:
      MaxIdle: 10
      MaxActive: 20
      Network: tcp
      Address: 127.0.0.1:6379
      Password: your password

B、数据存储到mysql

  • 修改配置文件conf.yaml如下
    dao: database
    database:
      Dialect: mysql
      Args: user:password@(127.0.0.1:3306)/dbname?charset=utf8&loc=Local&token=abc
  • 创建表
    CREATE TABLE `proxy` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `host` varchar(255) NOT NULL DEFAULT '',
      `port` int(11) NOT NULL DEFAULT '0',
      `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '0:无效,1:有效',
      `create_time` int(11) NOT NULL DEFAULT '0',
      `update_time` int(11) NOT NULL DEFAULT '0',
      `active_time` int(11) NOT NULL DEFAULT '0',
      `country` varchar(100) NOT NULL DEFAULT '',
      `region` varchar(100) NOT NULL DEFAULT '',
      `city` varchar(100) NOT NULL DEFAULT '',
      `isp` varchar(255) NOT NULL DEFAULT '',
      `check_count` int(11) NOT NULL DEFAULT '10',
      `source` varchar(50) NOT NULL DEFAULT '',
      `proto` varchar(20) NOT NULL DEFAULT 'http',
      `user` varchar(50) NOT NULL DEFAULT '',
      `password` varchar(50) NOT NULL DEFAULT '',
      `ping` int(11) NOT NULL DEFAULT '0',
      PRIMARY KEY (`id`) USING BTREE,
      UNIQUE KEY `IDX_HOST_PORT_PROTO` (`host`,`port`, `proto`) USING BTREE,
      KEY `IDX_STATUS` (`status`) USING BTREE,
      KEY `IDX_ACTIVE_TIME` (`active_time`) USING BTREE
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT

隧道代理配置

tunnel: 
  tunnelLevel: 1 //代理转发层级
  refresh: 10    //代理池自动刷新时间,单位秒
  debug: false   //是否debug
  strategy: round //指定节点选择策略,round - 轮询,random - 随机, fifo - 自上而下。默认值为round。
  maxFails: 100 //指定节点连接的最大失败次数,当与一个节点建立连接失败次数超过此设定值时,此节点会被标记为死亡节点
  failTimeout: 10 //定死亡节点的超时时间,当一个节点被标记为死亡节点后,在此设定的时间间隔内不会被选择使用
tunnels: //隧道代理监听的端口,可配多个
  -
    proto: http //协议:http、https、socks5等等
    host: 0.0.0.0 //host
    port: 8888 //监听端口
    users:  //授权用户,可配多个, 不开启用户较验不要配这个
      -
        username: root //用户名
        password: 123 //密码
        limiter: 1,10,2 //限流规则,1:1秒内,10:可访问10次,2: 限制2个并发

待开发

  • 支持socket5等其它协议代理采集、较验
  • 支持配置日志分级
  • 支持开启隧道代理服务:用户名密码验证、限流功能
  • 记录代理响应时间

感谢

  • 如果您觉得程序还不错,不妨点个星以鼓励一下,后续会更新更多ip源,谢谢!
  • 如果您对程序有任何建议和意见或者有更好的免费ip源,欢迎提交issue。
  • 感谢大神@ginuerzh 的开源项目提供隧道代理支持:gost

proxy-collect's People

Contributors

tongsq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

proxy-collect's Issues

报错

INFO[2023-07-14 02:31:39] local_ip_data.go:47:文件不存在,尝试从网络获取最新纯真 IP 库
ERRO[2023-07-14 02:31:40] local_ip_data.go:30:更新本地纯真ip库失败 err="zlib: invalid header"
ERRO[2023-07-14 02:31:40] local_ip_data.go:50:download local ip data fail err="zlib: invalid header"

更新后的bug

大大更新后运行几个小时报错,错误从dos窗口直接复制的,可能会不通顺!
看到job.go中“c.AddJob("@every 5m", scheduler.UpdateIpInfo{})”还在使用ip138查询,直接给注释了,不知道不是因为这个引起的报错,只会一点简单的php,基本靠猜。
如果方便的话请留个联系方式,方便沟通。联系方式可以写在“conf.yaml”的注释中,很隐蔽的-_-

“panic: runtime error: index out of range [0] with length 0”

goroutine 1409 [running]:
proxy-collect/service/ip.(*localIpService).readMode(...)
c:/go/code/proxy-collect-master/service/ip/local_ip_service.go:113
proxy-collect/service/ip.(*localIpService).Find(0xc00001e010, {0xc00db11620, 0xd})
c:/go/code/proxy-collect-master/service/ip/local_ip_service.go:75 +0x492
proxy-collect/service/ip.GetIpInfo({0xc00db11620, 0xd}, {0xc00db11618, 0x5})
c:/go/code/proxy-collect-master/service/ip/service.go:20 +0x45
proxy-collect/service.(*proxyService).CheckProxyAndSave(0x406e40?, {0xc00db11620, 0xd}, {0xc00db11618, 0x5}, {0x0, 0x0})
c:/go/code/proxy-collect-master/service/proxy_service.go:120 +0x62bproxy-collect/scheduler.CheckActiveIp.Run.func1()
c:/go/code/proxy-collect-master/scheduler/check_active_ip.go:25 +0x3a
github.com/tongsq/go-lib/component.(*Pool).workerStart(0xc000094c18, 0xc0016fcb40?, 0x0?)
C:/Users/taotao/go/pkg/mod/github.com/tongsq/[email protected]/component/task_pool.go:19 +0x62
created by github.com/tongsq/go-lib/component.(*Pool).RunTask
C:/Users/taotao/go/pkg/mod/github.com/tongsq/[email protected]/component/task_pool.go:31 +0x11e
exit status 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.