Sirenia
2012-11-17 16:14:37
Simple Skype IP resolver written with the api from my friends IP resolver.
Download here:
http://www.skype2ip.cu.cc/Skype2IP.jar
Click the resolved IP to copy it to your clipboard
Added the source for the people who are interested :)
Download here:
http://www.skype2ip.cu.cc/Skype2IP.jar
Click the resolved IP to copy it to your clipboard
Added the source for the people who are interested :)
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.datatransfer.StringSelection;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class Skype2IP extends JFrame{
public static final String BASE_URL = "http://www.skype2ip.cu.cc/api.php?username=";
private JLabel userLabel;
private JTextField userBox;
private JButton searchButton;
private JPanel northPanel;
private JLabel resultLabel;
public Skype2IP(){
super("Skype IP Resolver");
setLayout(new BorderLayout());
userLabel = new JLabel("Username:");
userLabel.setHorizontalAlignment(JLabel.CENTER);
userBox = new JTextField(15);
userBox.setHorizontalAlignment(JLabel.CENTER);
searchButton = new JButton("Search");
searchButton.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
final String username = userBox.getText().trim();
if(username.equals("")) return;
try{
resultLabel.setText(getIP(username, 50000));
}catch(IOException ex){
resultLabel.setText("Error Retrieving IP");
}
resultLabel.repaint();
}
}
);
northPanel = new JPanel(new GridLayout(1, 3));
northPanel.add(userLabel);
northPanel.add(userBox);
northPanel.add(searchButton);
resultLabel = new JLabel("-- Result --");
resultLabel.setHorizontalAlignment(JLabel.CENTER);
resultLabel.addMouseListener(
new MouseAdapter(){
public void mousePressed(MouseEvent e){
try{
final StringSelection selection = new StringSelection(resultLabel.getText());
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, null);
}catch(Exception ex){
JOptionPane.showMessageDialog(null, "Error copying ip", "Error", JOptionPane.ERROR_MESSAGE);
}
}
}
);
add(northPanel, BorderLayout.NORTH);
add(resultLabel, BorderLayout.SOUTH);
}
private String getIP(final String username, final int timeout) throws IOException {
final URL url = new URL(BASE_URL + username);
final HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setReadTimeout(timeout);
connection.setConnectTimeout(timeout);
connection.setRequestMethod("GET");
connection.addRequestProperty("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1309.0 Safari/537.17");
final Scanner reader = new Scanner(connection.getInputStream(), "UTF-8");
final String line = reader.nextLine().trim();
reader.close();
return line;
}
public static void main(String args[]) throws IOException {
Skype2IP window = new Skype2IP();
window.pack();
window.setLocationRelativeTo(null);
window.setVisible(true);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}