[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-bugs] #1967 [Tor Client]: The ancient architecture of Tor!!



#1967: The ancient architecture of Tor!!
-----------------+----------------------------------------------------------
 Reporter:  bee  |        Type:  enhancement
   Status:  new  |    Priority:  normal     
Milestone:       |   Component:  Tor Client 
  Version:       |    Keywords:             
   Parent:       |  
-----------------+----------------------------------------------------------
 Hi!!!!!!!!!!

 Phobos (andrew, i mean the blogger at Tor!!!) told me Nick Mathewson is
 the chief architect of Tor!!!!!!
 So i began to ask myself!!! what is the architecture of Tor?!!!!!!
 Well, what's the architecture of a software in general actually!!!!!! I
 recall i read something about it, while reading the instructions to write
 RPMs for red hat!!!!!
 So, when you're making a package, you've to split it in three packages!!!
 One package is for the "library", also known as "the shared object"!! The
 second one is for the "headers" for developing C software using that
 library! and the last one is the package within the main executable,
 usually a command line tool!!!!
 For example, you've a package with the library of "cURL" (it's a package
 with .so files), another one with the headers (they're files .h, it's
 named after cURL-devel) and the last one is "cURL" itself, with the
 command line tool!!!!!!!!!!!!!!
 Well, TOR is not respecting this architecture!!!!
 I think it would be better to have tor made in this way!!:
 * a libtor.so file!!
 * tor.h, the header for C
 * tor, the command line tool (a command line wrapper for the functions in
 libtor.so!!!)

 This new architecture is going to improve the whole tor-project a
 lot!!!!!!!!!!!!!
 Because you could have software, made to work only with Tor!!! YEAH!!, say
 "tor-ready"!!!!!!!!!!

 You could have a Chat system or P2P software built on "libtor"!!! And they
 could control everything of Tor, automatically and autonomously!!!!!!!
 They won't need to fork a new process and start the "tor" executable!!!
 And they won't need to open a local socks-server and a control port!!!!
 Because those software can be able to load the tor's library and they can
 directly call the functions they need!!!!!!!!!!!!!!!

 The current command line interface for Tor has to load "libtor" too, parse
 the command line and call the right functions!!!!!
 A software like VIDALIA, could do the same!!!! It could control tor
 loading the "libtor", without needing to fork its process and start the
 executable "tor"(like "tor.exe") and talk to it via sockets!!!!!!! (also,
 i don't understand why you use real TCP sockets instead of PIPEs or UNIX
 sockets to control Tor from VIDALIA in very local sessions!!)

 So, i began to look something in the source code of Tor!! and i think that
 creating a library could be very easy!!!!!!!
 At first i built tor!!! and this is the line MAKE uses to create the
 executable:
 {{{
 gcc  -g -O2 -Wall -g -O2 -fno-strict-aliasing -L/tmp/libevent/lib
  -Wl,-R/tmp/libevent/lib  -o tor buffers.o circuitbuild.o
  circuitlist.o circuituse.o command.o config.o connection.o
  connection_edge.o connection_or.o control.o cpuworker.o
  directory.o dirserv.o dirvote.o dns.o dnsserv.o geoip.o
  hibernate.o main.o  networkstatus.o onion.o policies.o reasons.o
  relay.o rendcommon.o rendclient.o rendmid.o rendservice.o
  rephist.o router.o routerlist.o routerparse.o eventdns.o
  tor_main.o ../common/libor.a ../common/libor-crypto.a
 -lz -levent -lssl -lcrypto   -lpthread -ldl
 }}}
 At first i think there is a minor flaw!!! "-g -O2 -Wall -g -O2" has "-g
 -O2" repeated two times, and this is purposeless!!!!!!!!but it's not a
 real bug!!!!
 Well, anyhow, i noticed that there are two files with names very easy to
 understand: tor_main.o and main.o!!!!
 So, i found the real "main()" in tor_main.o!!!!!!!! I think that if you
 remove it, it's enough to have a working shared object!!!!!!!!!

 I then managed to create this command line!!!!!
 {{{
 $ gcc -shared -Wall -g -O2 -fno-strict-aliasing -L/tmp/libevent/lib
  -Wl,-R/tmp/libevent/lib  -o libtor.so buffers.o circuitbuild.o
  circuitlist.o circuituse.o command.o config.o connection.o
  connection_edge.o connection_or.o control.o cpuworker.o
  directory.o dirserv.o dirvote.o dns.o dnsserv.o geoip.o
  hibernate.o main.o  networkstatus.o onion.o policies.o
  reasons.o relay.o rendcommon.o rendclient.o rendmid.o
  rendservice.o rephist.o router.o routerlist.o routerparse.o
  eventdns.o ../common/libor.a ../common/libor-crypto.a
 -lz -levent -lssl -lcrypto   -lpthread -ldl
 }}}
 You've to move in "./src/or" to use it!!!!!!!!! I removed a "-g -O2" and
 also the "tor_main.o" file from the linker!!!("linker" is the name of the
 step you use to create an executable using the object files!!!!!!!!!!)
 I also added the "-shared" switch because i want a shared library!! and i
 changed the output file name to "-o libtor.so"!!!!!!!!!!
 That command worked with no errors!!!!!!!!!!! but i don't know if it works
 for real!!!!!!!!!!!
 If i type "$ objdump -t libtor.so" i can read the names of exported
 functions!!!!!! This is a small piece of the objdumps list!!!!
 {{{
 000b6f90 g     F .text  00000259              tor_init
 00000000       F *UND*  00000000              munmap@@GLIBC_2.0
 0010c210 g     F .text  000000a0              crypto_dh_generate_public
 0007ced0 g     F .text  000002ad
 connection_get_by_type_state_rendquery
 000d9640 g     F .text  00000021
 is_legal_nickname_or_hexdigest
 00105de0 g     F .text  000000a5              smartlist_free
 0005f3d0 g     F .text  00000136              write_to_buf_zlib
 000665a0 g     F .text  000000a1              any_bridge_descriptors_known
 000d8740 g     F .text  0000041a              rep_hist_load_state
 0007b0d0 g     F .text  0000003f              connection_is_listener
 00000000       F *UND*  00000000              EVP_PKEY_assign
 0010d540 g     F .text  0000009e
 crypto_cipher_decrypt_init_cipher
 }}}
 I believe "tor_init" being the real function to call, to initialize the
 library!!!!!!!!!!!!!

 Well, this super analysis i made!!!!! could be useful for you!!!!!!!!!!!!
 It's because i think that you've to create the tor library as i
 suggested!! and then allow people to build software around it!!!!!!! The
 command line tool of Tor will be just a software, one of the many!! using
 the shared library!!!!
 Also vidalia could be made to work without executing
 "tor"/"tor.exe"!!!!!!!!!
 Perhaps, you could also build a whole web browser made to work with
 Tor!!!!!!!!!!!!! and a system to exchange files, emails, chat, and
 whatever absolutely autonomous!!! based only on libtor.so and working
 without requiring to start another process and connect to it!!!!!
 Yeah!!!, this is the right architecture for software!!!!!!! The KERNEL and
 the interfaces (GUI, graphical interfaces; or CLI, command line
 interfaces) should be split!!!!!!!!!!!
 If you write a software in C, or C++!!!, to download files from the NET,
 you can call the functions exported by libCURL!!!! You don't have to call
 the command line tool "cURL"!!!!!!!! YEAH!! i think the same has to be
 possible with Tor!!!!!!!!!!!!!!!!!!!!!

 bye!!!!!!!!!!!!!
 ~bee!!!!!

-- 
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/1967>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs