--- tmp65/grip-2.95/cddb.c Wed Oct 18 20:13:19 2000 +++ grip-2.95/cddb.c Sun May 13 21:47:38 2001 @@ -47,7 +47,7 @@ static void CDDBDisconnect(int sock); static void CDDBSkipHTTP(int sock); static int CDDBReadLine(int sock,char *inbuffer,int len); -static void CDDBMakeHello(CDDBHello *hello,char *hellobuf); +static void CDDBMakeHello(CDDBHello *hello,char *hellobuf, int evil); static void CDDBMakeRequest(CDDBServer *server, CDDBHello *hello, char *cmd,char *outbuf,int outlen); @@ -213,10 +213,18 @@ /* Make a 'hello' string from a cddb_hello structure */ -static void CDDBMakeHello(CDDBHello *hello,char *hellobuf) -{ - g_snprintf(hellobuf,256,"&hello=private+free.the.cddb+%s+%s", - hello->hello_program,hello->hello_version); +#define FAKEEMAIL "xxxyyyzz+hotmail.com" +#define FAKEAGENT "xmcd" +#define FAKEVERSION "2.6PL0" + +static void CDDBMakeHello(CDDBHello *hello,char *hellobuf, int evil) +{ + if (evil) + g_snprintf(hellobuf,256,"&hello=%s.cddb+%s+%s", FAKEEMAIL, + FAKEAGENT, FAKEVERSION); + else + g_snprintf(hellobuf,256,"&hello=private+free.the.cddb+%s+%s", + hello->hello_program,hello->hello_version); } /* Make a CDDB http request string */ @@ -225,19 +233,39 @@ CDDBHello *hello, char *cmd,char *outbuf,int outlen) { - char hellobuf[256]; + char hellobuf[256]; + int evil=0; - CDDBMakeHello(hello,hellobuf); + if (strstr(server->name, "cddb.org")) + evil=1; - if(server->use_proxy) - g_snprintf(outbuf,outlen, - "GET http://%s/%s?cmd=%s%s&proto=%s HTTP/1.1\r\nHost: %s\r\nUser-Agent: %s/%s\r\nAccept: text/plain\n\n", - server->name,server->cgi_prog,cmd,hellobuf, - GRIP_CDDB_LEVEL,server->name,Program,Version); + CDDBMakeHello(hello,hellobuf, evil); + + if (evil) + { + if(server->use_proxy) + g_snprintf(outbuf,outlen, + "GET http://%s/%s?cmd=%s%s&proto=%s HTTP/1.1\r\nHost: %s\r\nUser-Agent: Mozilla/4.7 (compatible; %s %s)\r\nAccept: text/plain\n\n", + FAKEAGENT, FAKEVERSION, cmd, hellobuf, + GRIP_CDDB_LEVEL,server->name,FAKEAGENT,FAKEVERSION); + else + g_snprintf(outbuf,outlen,"GET /%s?cmd=%s%s&proto=%s HTTP/1.1\r\nHost: %s\r\nUser-Agent: Mozilla/4.7 (compatible; %s %s)\r\nAccept: text/plain\n\n", + server->cgi_prog,cmd,hellobuf,GRIP_CDDB_LEVEL,server->name, + FAKEAGENT,FAKEVERSION); + } else - g_snprintf(outbuf,outlen,"GET /%s?cmd=%s%s&proto=%s HTTP/1.1\r\nHost: %s\r\nUser-Agent: %s/%s\r\nAccept: text/plain\n\n", - server->cgi_prog,cmd,hellobuf,GRIP_CDDB_LEVEL,server->name, - Program,Version); + { + if(server->use_proxy) + g_snprintf(outbuf,outlen, + "GET http://%s/%s?cmd=%s%s&proto=%s HTTP/1.1\r\nHost: %s\r\nUser-Agent: %s/%s\r\nAccept: text/plain\n\n", + server->name,server->cgi_prog,cmd,hellobuf, + GRIP_CDDB_LEVEL,server->name,Program,Version); + else + g_snprintf(outbuf,outlen,"GET /%s?cmd=%s%s&proto=%s HTTP/1.1\r\nHost: %s\r\nUser-Agent: %s/%s\r\nAccept: text/plain\n\n", + server->cgi_prog,cmd,hellobuf,GRIP_CDDB_LEVEL,server->name, + Program,Version); + } +/* printf("%s\n", outbuf); */ } /* Query the CDDB for the CD currently in the CD-ROM */