-
Notifications
You must be signed in to change notification settings - Fork 7
2. How to start and stop the proxy
Tamás Kőhegyi edited this page Jun 3, 2021
·
4 revisions
Starting and stopping the proxy server is easy. The code example below should give you all the necessary information:
import website.magyar.mitm.proxy.ProxyServer;
public class MyMitmProxy {
private final int PROXY_TIMEOUT = 5000; //5 sec
public ProxyServer proxyServer;
public int proxyPort;
public void startProxy() throws Exception {
proxyServer = new ProxyServer(0); //0 means random port
proxyServer.start(PROXY_TIMEOUT);
proxyPort = proxyServer.getPort(); //get the proxy server port
}
public void stopProxy() throws Exception {
if (proxyServer != null) {
proxyServer.stop();
}
}
}
The next step is define request/response interceptors - see details here.