R
R
recloudor2016-07-16 06:52:52
PHP
recloudor, 2016-07-16 06:52:52

How to send a POST request from a specific IP address?

There are several external ip, how to send a request from a specific one?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Pavlyuk, 2016-07-16
@recloudor

You need to create a client with a specific dialer

localAddr, err := net.ResolveIPAddr("ip", "192.168.1.2")
if err != nil {
  panic(err)
}
 
localTCPAddr := net.TCPAddr{
    IP: localAddr.IP,
}
 
client := &http.Client{
  Transport: &http.Transport{
    Dial: (&net.Dialer{
      LocalAddr: localTCPAddr,
    }).Dial,
  },
}

Then send a request through the client

L
Lindon_cano, 2016-07-16
@Lindon_cano

Raise the proxy which specify the desired address to the outside and send through it :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question