Giter VIP home page Giter VIP logo

Comments (4)

imroc avatar imroc commented on June 11, 2024

示例:

package main

import (
	"github.com/imroc/req/v3"
)

func main() {
	client := req.C().DevMode().
		SetProxyURL("socks5://127.0.0.1:10808").
		WrapRoundTripFunc(func(rt req.RoundTripper) req.RoundTripFunc {
			return func(req *req.Request) (resp *req.Response, err error) {
				req.URL.Host = "httpbin.org"
				return rt.RoundTrip(req)
			}
		})
	client.R().MustGet("https://54.237.103.220/ip")
}

from req.

NMZXYCDRL avatar NMZXYCDRL commented on June 11, 2024

非常感谢及时答复,示例程序设置代理是可用的,但绑定ip实际并没有生效,多运行几次代码在代理服务器上抓包可以看出来。复现也比较简单,示例里面的绑定iphttps://54.237.103.220/ip 改成任意一个ip,例如8.8.8.8 也能返回来结果。

from req.

imroc avatar imroc commented on June 11, 2024

哦,那应该是代理服务器按照host进行转发了,如果让代理按照ip转发,可以这样:

package main

import (
	"github.com/imroc/req/v3"
)

func main() {
	client := req.C().DevMode().
		SetProxyURL("socks5://127.0.0.1:10808").
		EnableInsecureSkipVerify()

	client.R().MustGet("https://54.237.103.220/ip")
}

但这个也要看服务端实现,如果服务端不接受ip作为host,那就不行,不过当前这个示例中的ip是可以的

from req.

NMZXYCDRL avatar NMZXYCDRL commented on June 11, 2024

但这个也要看服务端实现,如果服务端不接受ip作为host,那就不行,不过当前这个示例中的ip是可以的
如你所言,目标的确不是为了访问特定的ip,应该是访问域名后一组服务器中的特定一台,服务端一般都会有限制。再次感谢你

from req.

Related Issues (20)

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.