Olá PessoAll,
Estou estudando uma forma de criar um proxy local com java, apesar de ser
novato na linguagem.
Preciso monitorar o endereço que é acessado pelo Browse de forma
stand-alone.
Peguei o código listado abaixo (Server) e compilei, tudo ok.
Em seguida no browser mudei a configuração proxy para: LocalHost e
porta 2000 (conforme o codigo exige).
Executei o Server em uma janela DOS.
Fui para o browser e digitei um endereço (http://www.agestado.com.br).
No browser a página não apareceu (ficou com a mensagem de carregando...).
Sempre acontece isso em todas as tentativas que fiz. (Por que ?)
Indo para a janela DOS, onde estava rodando o Java, ocorreu tudo bem,
conforme mostrado abaixo no monitoramento.
Bem... alguem pode me ajudar com relação a resolver este problema. Indicar
um outro código fonte ou mostrar eventual erro no codigo anexo.
Minha necessidade é:
Um usuário estará utilizando seu browser normalmente. Rodando em paralelo,
o software java a ser criado vai interceptar os endereços que são digitados e
gravar um log.
Obrigado.
Segue os anexos.
================ monitoramento
C:\webmate>java server
Listening on port 2000
GET http://www.agestado.com.br/
HTTP/1.0
Accept: image/gif, image/x-xbitmap, image/jpeg,
image/pjpeg, application/vnd.ms-
excel, application/msword,
application/vnd.ms-powerpoint, application/x-comet, *
/*
Accept-Language: pt-br,ja;q=0.5
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 5.0;
Windows 98; DigExt)
Host: www.agestado.com.br
Proxy-Connection: Keep-Alive
====================================
CODIGO FONTE DO SERVER
=================
import java.net.*; import java.io.*; public class Server extends Thread { ServerSocket ss = null; public Server() { try { ss = new ServerSocket(2000); } catch (Exception e) { e.printStackTrace(); } System.out.println("Listening on port 2000"); this.start(); } public void run() { try { while(true) { Socket client = ss.accept(); handleClient( client); } } catch (IOException e) { System.out.println("Exception while listening for connection"); } } void handleClient( Socket s) throws IOException { DataInputStream in = new DataInputStream(s.getInputStream()); while (true) { String line = in.readLine(); if (line == null) return; System.out.println( line); } } public static void main(String []args) { Server s = new Server(); } } |
- Re: [java-list] Criar um Proxy local (StandAlone) Sérgio Luiz Tonsig
- Re: [java-list] Criar um Proxy local (StandAlone... lusoujava
- Re: [java-list] Criar um Proxy local (StandAlone... Bruno Diniz de Paula
- Re: [java-list] Criar um Proxy local (StandAlone... rricci
- Re: [java-list] Criar um Proxy local (StandA... Sérgio Luiz Tonsig
- Re: [java-list] Criar um Proxy local (StandAlone... Sven van ´t Veer
- Re: [java-list] Criar um Proxy local (StandA... Sérgio Luiz Tonsig
- Re: [java-list] Criar um Proxy local (StandAlone... mpserafim
- Re: [java-list] Criar um Proxy local (StandA... Sérgio Luiz Tonsig
- Re: [java-list] Criar um Proxy local (StandAlone... mpserafim
- Re: [java-list] Criar um Proxy local (StandA... Sérgio Luiz Tonsig