Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[JAVA] Using Proxies

Featured Replies

Originally written by Deque of EZ.


_____________________________________


These snippets show how to use proxies in Java.


 


ProxyHelper loads a proxylist of the format address:port:type (one proxy per line) and returns a proxy, if requested.


 


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.SocketAddress;
import java.util.LinkedList;
import java.util.Random;
 
public class ProxyHelper {
 
    private final Random rand;
    private final LinkedList<Proxy> proxies = new LinkedList<Proxy>();
 
    public ProxyHelper(String filename) {
        rand = new Random();
        loadProxies(filename);
    }
 
    public Proxy getAndRemoveRandomProxy() {
        int num = rand.nextInt(proxies.size());
        System.out.println(proxies.size());
        Proxy proxy = proxies.remove(num);
        System.out.println(proxy.address());
        return proxy;
    }
 
    // file format: "address:port:type"
    private void loadProxies(String filename) {
        try (BufferedReader br = new BufferedReader(new FileReader(filename))) {
            String line;
            while ((line = br.readLine()) != null) {
                String[] data = line.split(":");
                SocketAddress address = new InetSocketAddress(data[0],
                        Integer.parseInt(data[1]));
                Proxy.Type type = Proxy.Type.valueOf(data[2]);
                proxies.add(new Proxy(type, address));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

 


This is how you actually use the proxy:


 


Proxy proxy = proxyHelper.getAndRemoveRandomProxy();
URL url = new URL("http://evilzone.org");
URLConnection urlc = url.openConnection(proxy);
BufferedReader reader = new BufferedReader(new 
                        InputStreamReader(urlc.getInputStream()));

Guest
This topic is now closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.