Coder Social home page Coder Social logo

r00tarded / proxifier Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rookmoot/proxifier

0.0 1.0 0.0 21 KB

A fast, modern and intelligent proxy rotator perfect for crawling and scraping public data.

License: BSD 3-Clause "New" or "Revised" License

Go 100.00%

proxifier's Introduction

Proxifier

A fast, modern and intelligent proxy rotator perfect for crawling and scraping public data. Proxifier act as a proxy and remotely send and receive requests and responses from other proxies.

Getting Started

Firstly, just download and install proxifier.

go get github.com/rookmoot/proxifier

Example

First create a file that will contain the list of proxies. You NEED to change the ipAddress to a real proxy IP address. Likewise update port to the actual PORT. Otherwise your application will fail while trying to contact the proxy.

[
    {
       "ipAddress":"1.1.1.1",
       "port":9000,
       "protocols":[
          "https"
       ],
       "anonymityLevel":"elite",
       "source":"optional",
       "country":"us"
    },
    {
       "ipAddress":"2.2.2.2",
       "port":9000,
       "protocols":[
          "http"
       ],
       "anonymityLevel":"elite",
       "source":"-",
       "country":"us"
    }
]

Update the following example to change PROXY_PATH to the path of the list of proxies.

package main

import (
        "net"
        "net/http"

        redis "gopkg.in/redis.v5"

        "github.com/rookmoot/proxifier/forward"
        "github.com/rookmoot/proxifier/logger"
        "github.com/rookmoot/proxifier/proxy"
)

const (
        PROXY_PATH = "/home/joseph/work/src/github.com/rookmoot/proxifier/proxy_data.json"
)

var (
        log = logger.ColorLogger{}
)

type SimpleHandler struct {
        M *proxy.Manager
}

func (t *SimpleHandler) handleRequest(conn net.Conn) {
        log.Info("New client connected")

        fwd, err := forward.New(conn, log)
        if err != nil {
                log.Warn("%v", err)
                return
        }
        defer fwd.Close()

        fwd.OnSelectRemote(func(req *http.Request) (forward.Remote, error) {
                return t.M.GetProxy()
        })

        err = fwd.Forward()
        if err != nil {
                log.Warn("%v", err)
        }
}

func main() {
        log.Verbose = true
        log.Color = true

        r := redis.NewClient(
                &redis.Options{
                        Network:  "unix",
                        Addr:     "/var/run/redis/redis.sock",
                        Password: "",
                        DB:       0,
                },
        )

        proxyManager, err := proxy.NewManager(r, log)

        if err != nil {
                panic(err)
        }

        proxyManager.UpdateProxies(PROXY_PATH)

        t := SimpleHandler{
                M: proxyManager,
        }

        addr, err := net.ResolveTCPAddr("tcp", "localhost:8080")
        if err != nil {
                panic(err)
        }

        listener, err := net.ListenTCP("tcp", addr)
        if err != nil {
                panic(err)
        }
        defer listener.Close()

        for {
                conn, err := listener.AcceptTCP()
                if err != nil {
                        log.Warn("%v", err)
                }

                go t.handleRequest(conn)
        }
}

Try it !

To test it, just run for example :

curl -vx http://127.0.0.1:8080 http://httpbin.org/ip

If you want to try some HTTPS server, you may need to add a X-Proxifier-Https header in order to change your http:// url to https. For example if you want to test : https://httpbin.org/ip

curl -vx http://127.0.0.1:8080 -H "X-Proxifier-Https: On" http://httpbin.org/ip

Still in Beta

This project has just started, feel free to provide any feedback or pull requests.

proxifier's People

Contributors

rookmoot avatar databaseerror avatar

Watchers

James Cloos avatar

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.