Official eMule-Board: Help On Op_Searchrequest - Official eMule-Board

Jump to content


Page 1 of 1

Help On Op_Searchrequest

#1 User is offline   petermrg 

  • Member
  • PipPip
  • Group: Members
  • Posts: 29
  • Joined: 25-January 13

Posted 30 January 2013 - 10:47 AM

I'm working on an opensource emule server. The alpha version is almost done but I have some problems understanding the emule's OP_SEARCHREQUEST.

Do any emule developers have documentation about this operation?

I know it's encoded as a binary expression tree but I don't understand how are the contraints encoded. Also expressions for identical searches are are different in emule, amule and other clients.
All the documentation I found about the ed2k protocol is outdated or wrong.

Posted Image

How is the "minsize" constraint encoded?

PS: please, don't answer "look at the code". I'm already doing that (and getting crazy).

This post has been edited by petermrg: 30 January 2013 - 12:11 PM

eNode: eD2K/eMule server written in node.js. Fork it in GitHub
1

#2 User is offline   tHeWiZaRdOfDoS 

  • Man, what a bunch of jokers...
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5,391
  • Joined: 28-December 02

Posted 30 January 2013 - 12:40 PM

Even if you don't like it, the source code is the way to go. See CSearchResultsWnd::DoNewEd2kSearch. Within there's a call to GetSearchPacket (same source file) which pretty much contains everything you need.
Note the calls to AddAndAttr and their corresponding parameters, e.g.

Quote

if (pParams->ullMinSize > 0)
AddAndAttr(FT_FILESIZE, ED2K_SEARCH_OP_GREATER_EQUAL, pParams->ullMinSize);

After that, check the loop below

Quote

for (int j = 0; j < s_SearchExpr.m_aExpr.GetCount(); j++)

which is used to write the contraints (note that FT_FILESIZE may be added several times).
0

#3 User is offline   DavidXanatos 

  • Neo Dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,354
  • Joined: 23-April 04

Posted 30 January 2013 - 06:39 PM

Look inside class CSearchExprTarget it assembles the request into its binary form.
Posted Image
NeoLoader is a new file sharing client, supporting ed2k/eMule, Bittorent and one click hosters,
it is the first client to be able to download form multiple networks the same file.
NL provides the first fully decentralized scalable torrent and DDL keyword search,
it implements an own novel anonymous file sharing network, providing anonymity and deniability to its users,
as well as many other new features.
It is written in C++ with Qt and is available for Windows, Linux and MacOS.
0

#4 User is offline   petermrg 

  • Member
  • PipPip
  • Group: Members
  • Posts: 29
  • Joined: 25-January 13

Posted 31 January 2013 - 01:00 PM

Thanks Wizard and David!

Emule seems to encode constraints this way:
  • MinSize: (input * 1024 * 1024) - 1;
  • MaxSize: (input * 1024 * 1024) + 1;
  • Availability: input - 1;
  • Completed Sources: input - 1;
  • Bitrate: input - 1;
  • Duration: toSeconds(input) - 1;


This is my function to decode search expressions:
var searchExpr = function(token, type, value) {
    switch (type) {
        case 0xff: return 'str='+value;
        case 0x00: return ' AND ';
        case 0x01: return ' OR ';
        case 0x02: return ' NOT ';
        case 0x030001: return 'type='+value;
        case 0x040001: return 'ext='+value;
        case 0xd50001: return 'codec='+value;
        case 0x02000101: return 'size>'+value;
        case 0x02000102: return 'size<'+value;
        case 0x15000101: return 'sources>'+value;
        case 0xd4000101: return 'bitrate>'+value;
        case 0xd3000101: return 'duration>'+value;
        case 0x30000101: return 'sourcescompleted='+value;
        default: log.warn('searchExpr: unknown type: 0x'+type.toString(16)+'; token: 0x'+token.toString(16)+'; value: '+value);
    }
}

Buffer.prototype.getSearchString = function() {
    var token = this.getUInt8();
    switch (token) {
        case 0x01: // text match
            return searchExpr(token, 0xff, this.getString());
        case 0x02: // string
            var value = this.getString();
            var type = this.getUInt8();
            type+= this.getUInt16LE() * 0x100;
            return searchExpr(token, type, value);
        case 0x03: // 32bit value
            var value = this.getUInt32LE();
            var type = this.getUInt32LE();
            return searchExpr(token, type, value);
        case 0x08: // 64bit value
            var value = this.getUInt32LE();
            value+= this.getUInt32LE() * 0x10000 * 0x10000;
            var type = this.getUInt32LE();
            return searchExpr(token, type, value);
        case 0x00: // tree node
            var type = this.getUInt8();
            var s = '(' + this.getSearchString();
            s+= searchExpr(token, type, null);
            return s + this.getSearchString() + ')';
        default:
            log.warn('Buffer.getSearchString: unknown token: 0x'+token.toString(16));
    }
    return '';
};


Sample input search of text "aaa AND bbb OR ccc NOT ddd" and all possible constraints:
00000000: 0000 0000 0103 0061 6161 0001 0103 0062  .......aaa.....b
00000010: 6262 0002 0103 0063 6363 0103 0064 6464  bb.....ccc...ddd
00000020: 0000 0205 004d 5045 4734 0100 d500 0003  .....MPEG4..�...
00000030: 0f0e 0000 0101 00d3 0000 0399 0200 0001  .......�...�....
00000040: 0100 d400 0003 e603 0000 0101 0030 0000  ..�...�......0..
00000050: 03ff ff0f 1401 0100 0200 0008 0100 1043  .��............C
00000060: 0d00 0000 0201 0002 0000 0377 0300 0001  ...........w....
00000070: 0100 1502 0300 7171 7101 0004            ......qqq...


Sample output:
((str=aaa AND (str=bbb OR (str=ccc NOT str=ddd))) AND (codec=MPEG4 AND (duration>3599 AND (bitrate>665 AND (sourcescompleted=998 AND (size>336592895 AND (size<56959696897 AND (sources>887 AND ext=qqq))))))))


:+1:

This post has been edited by petermrg: 31 January 2013 - 01:05 PM

eNode: eD2K/eMule server written in node.js. Fork it in GitHub
0

  • Member Options

Page 1 of 1

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users