ABC_2_6_9.java
| Index Score | ||
|---|---|---|
![]() |
![]() |
omschaub.clientstuff.clientid |
![]() |
![]() |
AZCVSUpdater |
View: Reasons, Metrics, Source Code
These are the metrics that contribute to the Enerjy Score for this file, ranked by impact. So the metrics listed at the top influence the score to a greater extent that the metrics listed at the bottom.
/*
* Created on Jan 2, 2005
* Created by omschaub
*
*/
package omschaub.clientstuff.clientid;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import org.gudy.azureus2.plugins.clientid.ClientIDException;
import org.gudy.azureus2.plugins.clientid.ClientIDGenerator;
import org.gudy.azureus2.plugins.torrent.Torrent;
/**
* @author marc
*
*/
public class ABC_2_6_9 implements ClientIDGenerator{
private Map key_map = new HashMap();
public byte[]
generatePeerID(
Torrent torrent,
boolean for_tracker )
{
return( createPeerID());
}
public void
generateHTTPProperties(
Properties properties )
{
}
public String[]
filterHTTP(
String[] lines_in )
throws ClientIDException
{
/*FOR ABC
* GET /announce?info_hash=%8F%D2J%D0n%B8%AA%81%B7%99%E6q%10%D82%17C%21%AC%DA&peer_
* id=A269-----rhdS3Q0u2HQ&port=6882&uploaded=0&downloaded=0&left=349983&no_pee
* r_id=1&compact=1&event=started&key=rl-Vbj HTTP/1.0
* Host: 192.168.0.2:8080
* ~~~~~~~~~~~~~~~: ~~~~
* User-agent: BitTorrent/ABC-2.6.9
GET
/scrape?info_hash=%8f%d2%4a%d0%6e%b8%aa%81%b7%99%e6%71%10%d8%32%17%43%21%ac%
da HTTP/1.0
Host: 192.168.0.2:8080
~~~~~~~~~~~~~~~: ~~~~
User-agent: BitTorrent/ABC-2.6.9
*/
View.addElement("-----------------Start------------------");
for (int i=0;i<lines_in.length;i++)
{
View.addElement("From Azureus: " + lines_in[i]);
//System.out.println( "in: " + lines_in[i]);
}
String get_in = lines_in[0];
// scrape operation not performed by 3.4.2
if ( get_in.indexOf( "scrape?" ) != -1 ){
throw( new ClientIDException( "Scrape not supported by emulated client"));
}
// fiddle around with the url args
// remove HTTP/1.1 part
int last_space_pos = get_in.lastIndexOf(' ');
get_in = get_in.substring(0,last_space_pos).trim();
//int prefix_pos = get_in.indexOf('?');
int prefix_pos = get_in.indexOf("info_hash=" ) - 1;
String prefix = get_in.substring( 0, prefix_pos+1);
Map args = new HashMap();
int pos = prefix_pos+1;
while(true){
int p1 = get_in.indexOf('&', pos );
String arg;
if ( p1 == -1 ){
arg = get_in.substring( pos );
}else{
arg = get_in.substring( pos, p1 );
}
int e_pos = arg.indexOf('=');
args.put( arg.substring(0,e_pos), arg.substring( e_pos+1 ));
if ( p1 == -1 ){
break;
}else{
pos = p1+1;
}
}
String[] lines_out = new String[4];
String get_out = prefix;
String[] arg_list = {
"info_hash", "peer_id", "port", "uploaded", "downloaded", "left", "no_peer_id", "compact", "event", "key"
};
for (int i=0;i<arg_list.length;i++){
String key = arg_list[i];
String arg = (String)args.get(key);
if ( arg != null ){
if ( key.equals( "key" )){
arg = mapKeyValue( arg );
}
if ( key.equals( "peer_id")){
View.setClient(arg.substring(0,4) + " -- ABC Version 2.6.9");
}
get_out += (get_out==prefix?"":"&") + key + "=" + arg;
}
}
lines_out[0] = get_out + " HTTP/1.0";
for (int i=1;i<lines_in.length;i++){
if ( lines_in[i].toLowerCase().indexOf( "host:" ) != -1 ){
lines_out[1] = lines_in[i];
break;
}
}
lines_out[2] = "Accept-encoding: gzip";
lines_out[3] = "User-agent: BitTorrent/ABC-2.6.9";
for (int i=0;i<lines_out.length;i++){
View.addElement("Sent to Tracker: " + lines_out[i]);
//System.out.println( "out: " + lines_out[i]);
}
View.addElement("------------------End-------------------");
return( lines_out );
}
protected String
mapKeyValue(
String in )
{
String out = (String)key_map.get(in);
if ( out == null ){
out = "";
for (int i = 0; i < 8; i++) {
int pos = (int) ( Math.random() * chars.length());
out += chars.charAt(pos);
}
key_map.put( in, out );
}
return( out );
}
static final String chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
public static byte[]
createPeerID()
{
byte[] peerId = new byte[20];
byte[] version = "A269-----".getBytes();
for (int i = 0; i < 9; i++) {
peerId[i] = version[i];
}
for (int i = 9; i < 20; i++) {
int pos = (int) ( Math.random() * chars.length());
peerId[i] = (byte)chars.charAt(pos);
}
return( peerId );
}
}
The table below shows all metrics for ABC_2_6_9.java.




