📄 trackerstatus.java
字号:
public boolean verify(String host, SSLSession session)
{
return true;
}
{
this$0 = TrackerStatus.this;
super();
}
});
con = ssl_con;
} else
{
con = (HttpURLConnection)reqUrl.openConnection();
}
String user_agent = (String)http_properties.get("User-Agent");
if (user_agent != null)
con.setRequestProperty("User-Agent", user_agent);
con.addRequestProperty("Accept-Encoding", "gzip");
con.setRequestProperty("Connection", "close");
con.connect();
is = con.getInputStream();
String resulting_url_str = con.getURL().toString();
if (!reqUrl.toString().equals(resulting_url_str))
{
String marker = "permredirect=1";
int pos = resulting_url_str.indexOf(marker);
if (pos != -1)
{
pos--;
try
{
redirect_url = new URL(resulting_url_str.substring(0, pos));
}
catch (Throwable e)
{
Debug.printStackTrace(e);
}
}
}
String encoding = con.getHeaderField("content-encoding");
boolean gzip = encoding != null && encoding.equalsIgnoreCase("gzip");
if (gzip)
is = new GZIPInputStream(is);
data = new byte[1024];
num_read = 0;
do
{
int len = is.read(data);
if (len > 0)
{
message.write(data, 0, len);
num_read += len;
if (num_read > 0x20000)
{
message.reset();
throw new Exception("Tracker response invalid (too large)");
}
continue;
}
if (len != 0)
break;
Thread.sleep(20L);
} while (true);
goto _L1
Exception e;
e;
URL url;
if (Logger.isEnabled())
Logger.log(new LogEvent(LOGID, 3, (new StringBuilder()).append("Error from scrape interface ").append(scrapeURL).append(" : ").append(Debug.getNestedExceptionMessage(e)).toString()));
url = null;
if (is != null)
try
{
is.close();
}
catch (IOException e1) { }
return url;
_L1:
if (is != null)
try
{
is.close();
}
catch (IOException e1) { }
break MISSING_BLOCK_LABEL_512;
Exception exception;
exception;
if (is != null)
try
{
is.close();
}
catch (IOException e1) { }
throw exception;
return redirect_url;
}
protected boolean scrapeUDP(URL reqUrl, ByteArrayOutputStream message, List hashes, boolean do_auth_test)
throws Exception
{
Map rootMap;
Map files;
java.net.PasswordAuthentication auth;
boolean auth_ok;
rootMap = new HashMap();
files = new ByteEncodedKeyHashMap();
rootMap.put("files", files);
reqUrl = TRTrackerUtils.adjustURLForHosting(reqUrl);
auth = null;
auth_ok = false;
PRUDPPacketHandler handler;
InetSocketAddress destination;
String failure_reason;
int retry_loop;
if (do_auth_test && UrlUtils.queryHasParameter(reqUrl.getQuery(), "auth", false))
auth = SESecurityManager.getPasswordAuthentication("UDP Tracker", reqUrl);
int port = UDPNetworkManager.getSingleton().getUDPNonDataListeningPortNumber();
handler = PRUDPPacketHandlerFactory.getHandler(port);
destination = new InetSocketAddress(reqUrl.getHost(), reqUrl.getPort() != -1 ? reqUrl.getPort() : 80);
failure_reason = null;
retry_loop = 0;
_L3:
if (retry_loop >= 1)
break MISSING_BLOCK_LABEL_788;
PRUDPPacket reply;
PRUDPPacket connect_request = new PRUDPPacketRequestConnect();
reply = handler.sendAndReceive(auth, connect_request, destination);
if (reply.getAction() != 0)
break MISSING_BLOCK_LABEL_681;
PRUDPPacketReplyConnect connect_reply = (PRUDPPacketReplyConnect)reply;
long my_connection = connect_reply.getConnectionId();
PRUDPPacketRequestScrape scrape_request = new PRUDPPacketRequestScrape(my_connection, hashes);
reply = handler.sendAndReceive(auth, scrape_request, destination);
if (reply.getAction() != 2)
break MISSING_BLOCK_LABEL_619;
auth_ok = true;
if (PRUDPPacketTracker.VERSION != 1) goto _L2; else goto _L1
_L1:
boolean flag;
PRUDPPacketReplyScrape scrape_reply = (PRUDPPacketReplyScrape)reply;
byte reply_hashes[][] = scrape_reply.getHashes();
int complete[] = scrape_reply.getComplete();
int downloaded[] = scrape_reply.getDownloaded();
int incomplete[] = scrape_reply.getIncomplete();
for (int i = 0; i < reply_hashes.length; i++)
{
Map file = new HashMap();
byte resp_hash[] = reply_hashes[i];
files.put(new String(resp_hash, "ISO-8859-1"), file);
file.put("complete", new Long(complete[i]));
file.put("downloaded", new Long(downloaded[i]));
file.put("incomplete", new Long(incomplete[i]));
}
byte data[] = BEncoder.encode(rootMap);
message.write(data);
flag = true;
if (auth != null)
SESecurityManager.setPasswordAuthenticationOutcome(TRTrackerBTAnnouncerImpl.UDP_REALM, reqUrl, auth_ok);
return flag;
_L2:
PRUDPPacketReplyScrape2 scrape_reply = (PRUDPPacketReplyScrape2)reply;
int complete[] = scrape_reply.getComplete();
int downloaded[] = scrape_reply.getDownloaded();
int incomplete[] = scrape_reply.getIncomplete();
int i = 0;
for (Iterator it = hashes.iterator(); it.hasNext() && i < complete.length; i++)
{
HashWrapper hash = (HashWrapper)it.next();
Map file = new HashMap();
file.put("complete", new Long(complete[i]));
file.put("downloaded", new Long(downloaded[i]));
file.put("incomplete", new Long(incomplete[i]));
files.put(new String(hash.getBytes(), "ISO-8859-1"), file);
}
byte data[] = BEncoder.encode(rootMap);
message.write(data);
hash = 1;
if (auth != null)
SESecurityManager.setPasswordAuthenticationOutcome(TRTrackerBTAnnouncerImpl.UDP_REALM, reqUrl, auth_ok);
return hash;
try
{
failure_reason = ((PRUDPPacketReplyError)reply).getMessage();
if (Logger.isEnabled())
Logger.log(new LogEvent(LOGID, 3, (new StringBuilder()).append("Response from scrape interface ").append(reqUrl).append(" : ").append(failure_reason).toString()));
break MISSING_BLOCK_LABEL_788;
}
catch (PRUDPPacketHandlerException e)
{
if (e.getMessage() == null || e.getMessage().indexOf("timed out") == -1)
throw e;
failure_reason = "Timeout";
retry_loop++;
}
goto _L3
failure_reason = ((PRUDPPacketReplyError)reply).getMessage();
if (Logger.isEnabled())
Logger.log(new LogEvent(LOGID, 3, (new StringBuilder()).append("Response from scrape interface ").append(reqUrl).append(" : ").append(((PRUDPPacketReplyError)reply).getMessage()).toString()));
if (failure_reason != null)
{
rootMap.put("failure reason", failure_reason.getBytes());
rootMap.remove("files");
byte data[] = BEncoder.encode(rootMap);
message.write(data);
}
data = 0;
if (auth != null)
SESecurityManager.setPasswordAuthenticationOutcome(TRTrackerBTAnnouncerImpl.UDP_REALM, reqUrl, auth_ok);
return data;
Exception exception;
exception;
if (auth != null)
SESecurityManager.setPasswordAuthenticationOutcome(TRTrackerBTAnnouncerImpl.UDP_REALM, reqUrl, auth_ok);
throw exception;
}
protected String getURLParam(String url, String param)
{
int p1 = url.indexOf((new StringBuilder()).append(param).append("=").toString());
if (p1 == -1)
return null;
int p2 = url.indexOf("&", p1);
if (p2 == -1)
return url.substring(p1 + param.length() + 1);
else
return url.substring(p1 + param.length() + 1, p2);
}
protected TRTrackerScraperResponseImpl addHash(HashWrapper hash)
{
TRTrackerScraperResponseImpl response;
hashes_mon.enter();
response = (TRTrackerScraperResponseImpl)hashes.get(hash);
if (response == null)
{
response = new TRTrackerBTScraperResponseImpl(this, hash);
if (scrapeURL == null)
response.setStatus(1, (new StringBuilder()).append(MessageText.getString("Scrape.status.error")).append(MessageText.getString("Scrape.status.error.badURL")).toString());
else
response.setStatus(0, MessageText.getString("Scrape.status.initializing"));
response.setNextScrapeStartTime(checker.getNextScrapeCheckOn());
hashes.put(hash, response);
}
hashes_mon.exit();
break MISSING_BLOCK_LABEL_127;
Exception exception;
exception;
hashes_mon.exit();
throw exception;
scraper.scrapeReceived(response);
return response;
}
protected void removeHash(HashWrapper hash)
{
hashes_mon.enter();
hashes.remove(hash);
hashes_mon.exit();
break MISSING_BLOCK_LABEL_36;
Exception exception;
exception;
hashes_mon.exit();
throw exception;
}
protected URL getTrackerURL()
{
return tracker_url;
}
protected Map getHashes()
{
return hashes;
}
protected AEMonitor getHashesMonitor()
{
return hashes_mon;
}
protected void scrapeReceived(TRTrackerScraperResponse response)
{
scraper.scrapeReceived(response);
}
public boolean getSupportsMultipeHashScrapes()
{
return !bSingleHashScrapes;
}
protected String getString()
{
return (new StringBuilder()).append(tracker_url).append(", ").append(scrapeURL).append(", multi-scrape=").append(!bSingleHashScrapes).toString();
}
public int getNumActiveScrapes()
{
return numActiveScrapes;
}
static
{
LOGID = LogIDs.TRACKER;
PRUDPTrackerCodecs.registerCodecs();
COConfigurationManager.addAndFireParameterListener("Server Enable UDP", new ParameterListener() {
public void parameterChanged(String parameterName)
{
TrackerStatus.udpScrapeEnabled = COConfigurationManager.getBooleanParameter("Server Enable UDP");
}
});
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -