1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541 |
- #ifndef __OR_H
- #define __OR_H
- #define OR_H_ID "$Id$"
- #include "orconfig.h"
- #ifdef MS_WINDOWS
- #define WIN32_WINNT 0x400
- #define _WIN32_WINNT 0x400
- #define WIN32_LEAN_AND_MEAN
- #endif
- #include <stdio.h>
- #include <stdlib.h>
- #ifdef HAVE_UNISTD_H
- #include <unistd.h>
- #endif
- #ifdef HAVE_STRING_H
- #include <string.h>
- #endif
- #ifdef HAVE_SIGNAL_H
- #include <signal.h>
- #endif
- #ifdef HAVE_NETDB_H
- #include <netdb.h>
- #endif
- #ifdef HAVE_CTYPE_H
- #include <ctype.h>
- #endif
- #ifdef HAVE_SYS_PARAM_H
- #include <sys/param.h> /* FreeBSD needs this to know what version it is */
- #endif
- #include "../common/torint.h"
- #ifdef HAVE_SYS_WAIT_H
- #include <sys/wait.h>
- #endif
- #ifdef HAVE_SYS_FCNTL_H
- #include <sys/fcntl.h>
- #endif
- #ifdef HAVE_FCNTL_H
- #include <fcntl.h>
- #endif
- #ifdef HAVE_SYS_IOCTL_H
- #include <sys/ioctl.h>
- #endif
- #ifdef HAVE_SYS_SOCKET_H
- #include <sys/socket.h>
- #endif
- #ifdef HAVE_SYS_UN_H
- #include <sys/un.h>
- #endif
- #ifdef HAVE_SYS_TIME_H
- #include <sys/time.h>
- #endif
- #ifdef HAVE_SYS_STAT_H
- #include <sys/stat.h>
- #endif
- #ifdef HAVE_NETINET_IN_H
- #include <netinet/in.h>
- #endif
- #ifdef HAVE_ARPA_INET_H
- #include <arpa/inet.h>
- #endif
- #ifdef HAVE_ERRNO_H
- #include <errno.h>
- #endif
- #ifdef HAVE_ASSERT_H
- #include <assert.h>
- #endif
- #ifdef HAVE_TIME_H
- #include <time.h>
- #endif
- #if defined(CYGWIN) || defined(__CYGWIN__)
- #define MAXCONNECTIONS 3200
- #else
- #define MAXCONNECTIONS 15000
- #endif
- #ifdef MS_WINDOWS
- #if defined(_MSC_VER) && (_MSC_VER <= 1300)
- #include <winsock.h>
- #else
- #include <winsock2.h>
- #include <ws2tcpip.h>
- #endif
- #endif
- #ifdef MS_WINDOWS
- #include <io.h>
- #include <process.h>
- #include <direct.h>
- #include <windows.h>
- #define snprintf _snprintf
- #endif
- #include <event.h>
- #include "../common/crypto.h"
- #include "../common/tortls.h"
- #include "../common/log.h"
- #include "../common/compat.h"
- #include "../common/container.h"
- #include "../common/util.h"
- #include "../common/torgzip.h"
- #ifndef SIGHUP
- #define SIGHUP 1
- #endif
- #ifndef SIGINT
- #define SIGINT 2
- #endif
- #ifndef SIGUSR1
- #define SIGUSR1 10
- #endif
- #ifndef SIGUSR2
- #define SIGUSR2 12
- #endif
- #ifndef SIGTERM
- #define SIGTERM 15
- #endif
- #define SIGNEWNYM 129
- #define SIGCLEARDNSCACHE 130
- #if (SIZEOF_CELL_T != 0)
- #define cell_t tor_cell_t
- #endif
- #define FULL_V1_DIRECTORIES
- #define INCLUDE_BW_INFO_IN_ROUTERDESCS
- #define MAX_NICKNAME_LEN 19
- #define MAX_HEX_NICKNAME_LEN (HEX_DIGEST_LEN+1)
- #define MAX_VERBOSE_NICKNAME_LEN (1+HEX_DIGEST_LEN+1+MAX_NICKNAME_LEN)
- #define MAX_BUF_SIZE ((1<<24)-1)
- #define MAX_DIR_DL_SIZE MAX_BUF_SIZE
- #define MAX_HEADERS_SIZE 50000
- #define MAX_DIR_UL_SIZE 500000
- #define MAX_DNS_ENTRY_AGE (30*60)
- #define DEFAULT_DNS_TTL (30*60)
- #define MAX_DNS_TTL (3*60*60)
- #define MIN_DNS_TTL (60)
- #define MIN_ONION_KEY_LIFETIME (7*24*60*60)
- #define MAX_SSL_KEY_LIFETIME (2*60*60)
- #define ROUTER_MAX_AGE (60*60*48)
- #define ROUTER_MAX_AGE_TO_PUBLISH (60*60*20)
- #define OLD_ROUTER_DESC_MAX_AGE (60*60*24*5)
- #define NETWORKSTATUS_MAX_AGE (60*60*24)
- typedef enum {
- CIRC_ID_TYPE_LOWER=0,
- CIRC_ID_TYPE_HIGHER=1,
-
- CIRC_ID_TYPE_NEITHER=2
- } circ_id_type_t;
- #define _CONN_TYPE_MIN 3
- #define CONN_TYPE_OR_LISTENER 3
- #define CONN_TYPE_OR 4
- #define CONN_TYPE_EXIT 5
- #define CONN_TYPE_AP_LISTENER 6
- #define CONN_TYPE_AP 7
- #define CONN_TYPE_DIR_LISTENER 8
- #define CONN_TYPE_DIR 9
- #define CONN_TYPE_CPUWORKER 10
- #define CONN_TYPE_CONTROL_LISTENER 11
- #define CONN_TYPE_CONTROL 12
- #define CONN_TYPE_AP_TRANS_LISTENER 13
- #define CONN_TYPE_AP_NATD_LISTENER 14
- #define CONN_TYPE_AP_DNS_LISTENER 15
- #define _CONN_TYPE_MAX 15
- #define CONN_IS_EDGE(x) \
- ((x)->type == CONN_TYPE_EXIT || (x)->type == CONN_TYPE_AP)
- #define LISTENER_STATE_READY 0
- #define _CPUWORKER_STATE_MIN 1
- #define CPUWORKER_STATE_IDLE 1
- #define CPUWORKER_STATE_BUSY_ONION 2
- #define _CPUWORKER_STATE_MAX 2
- #define CPUWORKER_TASK_ONION CPUWORKER_STATE_BUSY_ONION
- #define _OR_CONN_STATE_MIN 1
- #define OR_CONN_STATE_CONNECTING 1
- #define OR_CONN_STATE_PROXY_FLUSHING 2
- #define OR_CONN_STATE_PROXY_READING 3
- #define OR_CONN_STATE_HANDSHAKING 4
- #define OR_CONN_STATE_OPEN 5
- #define _OR_CONN_STATE_MAX 5
- #define _EXIT_CONN_STATE_MIN 1
- #define EXIT_CONN_STATE_RESOLVING 1
- #define EXIT_CONN_STATE_CONNECTING 2
- #define EXIT_CONN_STATE_OPEN 3
- #define EXIT_CONN_STATE_RESOLVEFAILED 4
- #define _EXIT_CONN_STATE_MAX 4
- #define _AP_CONN_STATE_MIN 5
- #define AP_CONN_STATE_SOCKS_WAIT 5
- #define AP_CONN_STATE_RENDDESC_WAIT 6
- #define AP_CONN_STATE_CONTROLLER_WAIT 7
- #define AP_CONN_STATE_CIRCUIT_WAIT 8
- #define AP_CONN_STATE_CONNECT_WAIT 9
- #define AP_CONN_STATE_RESOLVE_WAIT 10
- #define AP_CONN_STATE_OPEN 11
- #define AP_CONN_STATE_NATD_WAIT 12
- #define _AP_CONN_STATE_MAX 12
- #define AP_CONN_STATE_IS_UNATTACHED(s) \
- ((s) <= AP_CONN_STATE_CIRCUIT_WAIT || (s) == AP_CONN_STATE_NATD_WAIT)
- #define _DIR_CONN_STATE_MIN 1
- #define DIR_CONN_STATE_CONNECTING 1
- #define DIR_CONN_STATE_CLIENT_SENDING 2
- #define DIR_CONN_STATE_CLIENT_READING 3
- #define DIR_CONN_STATE_CLIENT_FINISHED 4
- #define DIR_CONN_STATE_SERVER_COMMAND_WAIT 5
- #define DIR_CONN_STATE_SERVER_WRITING 6
- #define _DIR_CONN_STATE_MAX 6
- #define DIR_CONN_IS_SERVER(conn) ((conn)->purpose == DIR_PURPOSE_SERVER)
- #define _CONTROL_CONN_STATE_MIN 1
- #define CONTROL_CONN_STATE_OPEN 1
- #define CONTROL_CONN_STATE_NEEDAUTH 2
- #define _CONTROL_CONN_STATE_MAX 2
- #define _DIR_PURPOSE_MIN 1
- #define DIR_PURPOSE_FETCH_DIR 1
- #define DIR_PURPOSE_FETCH_RUNNING_LIST 2
- #define DIR_PURPOSE_FETCH_RENDDESC 3
- #define DIR_PURPOSE_HAS_FETCHED_RENDDESC 4
- #define DIR_PURPOSE_FETCH_NETWORKSTATUS 5
- #define DIR_PURPOSE_FETCH_SERVERDESC 6
- #define DIR_PURPOSE_FETCH_EXTRAINFO 7
- #define DIR_PURPOSE_UPLOAD_DIR 8
- #define DIR_PURPOSE_UPLOAD_RENDDESC 9
- #define DIR_PURPOSE_UPLOAD_VOTE 10
- #define DIR_PURPOSE_FETCH_VOTE 11
- #define DIR_PURPOSE_UPLOAD_SIGNATURES 12
- #define DIR_PURPOSE_SERVER 13
- #define _DIR_PURPOSE_MAX 13
- #define _EXIT_PURPOSE_MIN 1
- #define EXIT_PURPOSE_CONNECT 1
- #define EXIT_PURPOSE_RESOLVE 2
- #define _EXIT_PURPOSE_MAX 2
- #define CIRCUIT_STATE_BUILDING 0
- #define CIRCUIT_STATE_ONIONSKIN_PENDING 1
- #define CIRCUIT_STATE_OR_WAIT 2
- #define CIRCUIT_STATE_OPEN 3
- #define _CIRCUIT_PURPOSE_MIN 1
- #define _CIRCUIT_PURPOSE_OR_MIN 1
- #define CIRCUIT_PURPOSE_OR 1
- #define CIRCUIT_PURPOSE_INTRO_POINT 2
- #define CIRCUIT_PURPOSE_REND_POINT_WAITING 3
- #define CIRCUIT_PURPOSE_REND_ESTABLISHED 4
- #define _CIRCUIT_PURPOSE_OR_MAX 4
- #define CIRCUIT_PURPOSE_C_GENERAL 5
- #define CIRCUIT_PURPOSE_C_INTRODUCING 6
- #define CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT 7
- #define CIRCUIT_PURPOSE_C_INTRODUCE_ACKED 8
- #define CIRCUIT_PURPOSE_C_ESTABLISH_REND 9
- #define CIRCUIT_PURPOSE_C_REND_READY 10
- #define CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED 11
- #define CIRCUIT_PURPOSE_C_REND_JOINED 12
- #define CIRCUIT_PURPOSE_S_ESTABLISH_INTRO 13
- #define CIRCUIT_PURPOSE_S_INTRO 14
- #define CIRCUIT_PURPOSE_S_CONNECT_REND 15
- #define CIRCUIT_PURPOSE_S_REND_JOINED 16
- #define CIRCUIT_PURPOSE_TESTING 17
- #define CIRCUIT_PURPOSE_CONTROLLER 18
- #define _CIRCUIT_PURPOSE_MAX 18
- #define CIRCUIT_PURPOSE_IS_ORIGIN(p) ((p)>_CIRCUIT_PURPOSE_OR_MAX)
- #define CIRCUIT_IS_ORIGIN(c) (CIRCUIT_PURPOSE_IS_ORIGIN((c)->purpose))
- #define MIN_CIRCUITS_HANDLING_STREAM 2
- #define RELAY_COMMAND_BEGIN 1
- #define RELAY_COMMAND_DATA 2
- #define RELAY_COMMAND_END 3
- #define RELAY_COMMAND_CONNECTED 4
- #define RELAY_COMMAND_SENDME 5
- #define RELAY_COMMAND_EXTEND 6
- #define RELAY_COMMAND_EXTENDED 7
- #define RELAY_COMMAND_TRUNCATE 8
- #define RELAY_COMMAND_TRUNCATED 9
- #define RELAY_COMMAND_DROP 10
- #define RELAY_COMMAND_RESOLVE 11
- #define RELAY_COMMAND_RESOLVED 12
- #define RELAY_COMMAND_BEGIN_DIR 13
- #define RELAY_COMMAND_ESTABLISH_INTRO 32
- #define RELAY_COMMAND_ESTABLISH_RENDEZVOUS 33
- #define RELAY_COMMAND_INTRODUCE1 34
- #define RELAY_COMMAND_INTRODUCE2 35
- #define RELAY_COMMAND_RENDEZVOUS1 36
- #define RELAY_COMMAND_RENDEZVOUS2 37
- #define RELAY_COMMAND_INTRO_ESTABLISHED 38
- #define RELAY_COMMAND_RENDEZVOUS_ESTABLISHED 39
- #define RELAY_COMMAND_INTRODUCE_ACK 40
- #define END_OR_CONN_REASON_DONE 1
- #define END_OR_CONN_REASON_TCP_REFUSED 2
- #define END_OR_CONN_REASON_OR_IDENTITY 3
- #define END_OR_CONN_REASON_TLS_CONNRESET 4
- #define END_OR_CONN_REASON_TLS_TIMEOUT 5
- #define END_OR_CONN_REASON_TLS_NO_ROUTE 6
- #define END_OR_CONN_REASON_TLS_IO_ERROR 7
- #define END_OR_CONN_REASON_TLS_MISC 8
- #define END_STREAM_REASON_MISC 1
- #define END_STREAM_REASON_RESOLVEFAILED 2
- #define END_STREAM_REASON_CONNECTREFUSED 3
- #define END_STREAM_REASON_EXITPOLICY 4
- #define END_STREAM_REASON_DESTROY 5
- #define END_STREAM_REASON_DONE 6
- #define END_STREAM_REASON_TIMEOUT 7
- #define END_STREAM_REASON_HIBERNATING 9
- #define END_STREAM_REASON_INTERNAL 10
- #define END_STREAM_REASON_RESOURCELIMIT 11
- #define END_STREAM_REASON_CONNRESET 12
- #define END_STREAM_REASON_TORPROTOCOL 13
- #define END_STREAM_REASON_NOTDIRECTORY 14
- #define END_STREAM_REASON_CANT_ATTACH 257
- #define END_STREAM_REASON_NET_UNREACHABLE 258
- #define END_STREAM_REASON_SOCKSPROTOCOL 259
- #define END_STREAM_REASON_CANT_FETCH_ORIG_DEST 260
- #define END_STREAM_REASON_INVALID_NATD_DEST 261
- #define END_STREAM_REASON_MASK 511
- #define END_STREAM_REASON_FLAG_REMOTE 512
- #define END_STREAM_REASON_FLAG_ALREADY_SENT_CLOSED 1024
- #define END_STREAM_REASON_FLAG_ALREADY_SOCKS_REPLIED 2048
- #define REMAP_STREAM_SOURCE_CACHE 1
- #define REMAP_STREAM_SOURCE_EXIT 2
- #define RESOLVED_TYPE_HOSTNAME 0
- #define RESOLVED_TYPE_IPV4 4
- #define RESOLVED_TYPE_IPV6 6
- #define RESOLVED_TYPE_ERROR_TRANSIENT 0xF0
- #define RESOLVED_TYPE_ERROR 0xF1
- #define END_CIRC_REASON_NOPATH -2
- #define END_CIRC_AT_ORIGIN -1
- #define _END_CIRC_REASON_MIN 0
- #define END_CIRC_REASON_NONE 0
- #define END_CIRC_REASON_TORPROTOCOL 1
- #define END_CIRC_REASON_INTERNAL 2
- #define END_CIRC_REASON_REQUESTED 3
- #define END_CIRC_REASON_HIBERNATING 4
- #define END_CIRC_REASON_RESOURCELIMIT 5
- #define END_CIRC_REASON_CONNECTFAILED 6
- #define END_CIRC_REASON_OR_IDENTITY 7
- #define END_CIRC_REASON_OR_CONN_CLOSED 8
- #define END_CIRC_REASON_FINISHED 9
- #define END_CIRC_REASON_TIMEOUT 10
- #define END_CIRC_REASON_DESTROYED 11
- #define END_CIRC_REASON_NOSUCHSERVICE 12
- #define _END_CIRC_REASON_MAX 12
- #define END_CIRC_REASON_FLAG_REMOTE 512
- #define REND_SERVICE_ID_LEN 16
- #define CELL_DIRECTION_IN 1
- #define CELL_DIRECTION_OUT 2
- #ifdef TOR_PERF
- #define CIRCWINDOW_START 10000
- #define CIRCWINDOW_INCREMENT 1000
- #define STREAMWINDOW_START 5000
- #define STREAMWINDOW_INCREMENT 500
- #else
- #define CIRCWINDOW_START 1000
- #define CIRCWINDOW_INCREMENT 100
- #define STREAMWINDOW_START 500
- #define STREAMWINDOW_INCREMENT 50
- #endif
- #define CELL_PADDING 0
- #define CELL_CREATE 1
- #define CELL_CREATED 2
- #define CELL_RELAY 3
- #define CELL_DESTROY 4
- #define CELL_CREATE_FAST 5
- #define CELL_CREATED_FAST 6
- #define TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT (20*60)
- #define LEGAL_NICKNAME_CHARACTERS \
- "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
- #define DEFAULT_CLIENT_NICKNAME "client"
- #define SOCKS4_NETWORK_LEN 8
- typedef enum {
- SOCKS5_SUCCEEDED = 0x00,
- SOCKS5_GENERAL_ERROR = 0x01,
- SOCKS5_NOT_ALLOWED = 0x02,
- SOCKS5_NET_UNREACHABLE = 0x03,
- SOCKS5_HOST_UNREACHABLE = 0x04,
- SOCKS5_CONNECTION_REFUSED = 0x05,
- SOCKS5_TTL_EXPIRED = 0x06,
- SOCKS5_COMMAND_NOT_SUPPORTED = 0x07,
- SOCKS5_ADDRESS_TYPE_NOT_SUPPORTED = 0x08,
- } socks5_reply_status_t;
- #define CELL_PAYLOAD_SIZE 509
- #define CELL_NETWORK_SIZE 512
- #define RELAY_HEADER_SIZE (1+2+2+4+2)
- #define RELAY_PAYLOAD_SIZE (CELL_PAYLOAD_SIZE-RELAY_HEADER_SIZE)
- typedef struct cell_t cell_t;
- struct cell_t {
- uint16_t circ_id;
- uint8_t command;
- char payload[CELL_PAYLOAD_SIZE];
- };
- typedef struct packed_cell_t packed_cell_t;
- struct packed_cell_t {
- struct packed_cell_t *next;
- char body[CELL_NETWORK_SIZE];
- };
- typedef struct cell_queue_t {
- packed_cell_t *head;
- packed_cell_t *tail;
- int n;
- } cell_queue_t;
- typedef struct {
- uint8_t command;
- uint16_t recognized;
- uint16_t stream_id;
- char integrity[4];
- uint16_t length;
- } relay_header_t;
- typedef struct buf_t buf_t;
- typedef struct socks_request_t socks_request_t;
- #define BASE_CONNECTION_MAGIC 0x7C3C304Eu
- #define OR_CONNECTION_MAGIC 0x7D31FF03u
- #define EDGE_CONNECTION_MAGIC 0xF0374013u
- #define DIR_CONNECTION_MAGIC 0x9988ffeeu
- #define CONTROL_CONNECTION_MAGIC 0x8abc765du
- typedef struct connection_t {
- uint32_t magic;
- uint8_t type;
- uint8_t state;
- uint8_t purpose;
-
- unsigned read_blocked_on_bw:1;
- unsigned write_blocked_on_bw:1;
- unsigned hold_open_until_flushed:1;
- unsigned int inbuf_reached_eof:1;
- unsigned int edge_has_sent_end:1;
-
- unsigned int edge_blocked_on_circ:1;
-
- unsigned int or_is_obsolete:1;
-
- unsigned int chosen_exit_optional:1;
- int s;
- int conn_array_index;
- struct event *read_event;
- struct event *write_event;
- buf_t *inbuf;
- buf_t *outbuf;
- size_t outbuf_flushlen;
- time_t timestamp_lastread;
- time_t timestamp_lastwritten;
- time_t timestamp_created;
-
- int socket_family;
- uint32_t addr;
- uint16_t port;
- uint16_t marked_for_close;
- const char *marked_for_close_file;
- char *address;
-
- struct connection_t *linked_conn;
-
- unsigned int linked:1;
-
- unsigned int reading_from_linked_conn:1;
-
- unsigned int writing_to_linked_conn:1;
-
- unsigned int active_on_link:1;
-
- struct evdns_server_port *dns_server_port;
- } connection_t;
- typedef struct or_connection_t {
- connection_t _base;
-
- char identity_digest[DIGEST_LEN];
- char *nickname;
- tor_tls_t *tls;
- int tls_error;
-
- uint8_t client_used:1;
- circ_id_type_t circ_id_type:2;
- uint16_t next_circ_id;
- time_t timestamp_lastempty;
-
- int bandwidthrate;
- int bandwidthburst;
- int read_bucket;
- int n_circuits;
-
- struct circuit_t *active_circuits;
- struct or_connection_t *next_with_same_id;
- } or_connection_t;
- typedef struct edge_connection_t {
- connection_t _base;
- struct edge_connection_t *next_stream;
- struct crypt_path_t *cpath_layer;
- int package_window;
- int deliver_window;
-
- char *chosen_exit_name;
- socks_request_t *socks_request;
- struct circuit_t *on_circuit;
- uint32_t address_ttl;
- uint16_t stream_id;
-
- uint16_t end_reason;
-
-
- uint32_t global_identifier;
-
- uint32_t n_read;
-
- uint32_t n_written;
- char rend_query[REND_SERVICE_ID_LEN+1];
-
- uint8_t num_socks_retries;
-
- unsigned int is_dns_request : 1;
-
- struct evdns_server_request *dns_server_request;
- } edge_connection_t;
- typedef struct dir_connection_t {
- connection_t _base;
- char *requested_resource;
- unsigned int dirconn_direct:1;
-
-
- enum {
- DIR_SPOOL_NONE=0, DIR_SPOOL_SERVER_BY_DIGEST, DIR_SPOOL_SERVER_BY_FP,
- DIR_SPOOL_EXTRA_BY_DIGEST, DIR_SPOOL_EXTRA_BY_FP,
- DIR_SPOOL_CACHED_DIR, DIR_SPOOL_NETWORKSTATUS
- } dir_spool_src : 3;
-
- uint8_t router_purpose;
-
- smartlist_t *fingerprint_stack;
-
- struct cached_dir_t *cached_dir;
-
- off_t cached_dir_offset;
-
- tor_zlib_state_t *zlib_state;
- char rend_query[REND_SERVICE_ID_LEN+1];
- char identity_digest[DIGEST_LEN];
- } dir_connection_t;
- typedef struct control_connection_t {
- connection_t _base;
- uint32_t event_mask;
- unsigned int use_long_names:1;
-
- unsigned int use_extended_events:1;
- uint32_t incoming_cmd_len;
- uint32_t incoming_cmd_cur_len;
- char *incoming_cmd;
-
- uint16_t incoming_cmd_type;
- } control_connection_t;
- #define TO_CONN(c) (&(((c)->_base)))
- #define DOWNCAST(to, ptr) ((to*)SUBTYPE_P(ptr, to, _base))
- static or_connection_t *TO_OR_CONN(connection_t *);
- static dir_connection_t *TO_DIR_CONN(connection_t *);
- static edge_connection_t *TO_EDGE_CONN(connection_t *);
- static control_connection_t *TO_CONTROL_CONN(connection_t *);
- static INLINE or_connection_t *TO_OR_CONN(connection_t *c)
- {
- tor_assert(c->magic == OR_CONNECTION_MAGIC);
- return DOWNCAST(or_connection_t, c);
- }
- static INLINE dir_connection_t *TO_DIR_CONN(connection_t *c)
- {
- tor_assert(c->magic == DIR_CONNECTION_MAGIC);
- return DOWNCAST(dir_connection_t, c);
- }
- static INLINE edge_connection_t *TO_EDGE_CONN(connection_t *c)
- {
- tor_assert(c->magic == EDGE_CONNECTION_MAGIC);
- return DOWNCAST(edge_connection_t, c);
- }
- static INLINE control_connection_t *TO_CONTROL_CONN(connection_t *c)
- {
- tor_assert(c->magic == CONTROL_CONNECTION_MAGIC);
- return DOWNCAST(control_connection_t, c);
- }
- typedef enum {
- ADDR_POLICY_ACCEPT=1,
- ADDR_POLICY_REJECT=2,
- } addr_policy_action_t;
- typedef struct addr_policy_t {
- addr_policy_action_t policy_type;
- char *string;
-
- uint32_t addr;
- maskbits_t maskbits;
- uint16_t prt_min;
- uint16_t prt_max;
- struct addr_policy_t *next;
- } addr_policy_t;
- typedef struct cached_dir_t {
- char *dir;
- char *dir_z;
- size_t dir_len;
- size_t dir_z_len;
- time_t published;
- int refcnt;
- } cached_dir_t;
- typedef enum {
-
- SAVED_NOWHERE=0,
-
- SAVED_IN_CACHE,
-
-
- SAVED_IN_JOURNAL
- } saved_location_t;
- typedef struct download_status_t {
- time_t next_attempt_at;
- uint8_t n_download_failures;
- } download_status_t;
- typedef struct signed_descriptor_t {
-
- char *signed_descriptor_body;
-
- size_t signed_descriptor_len;
-
- char signed_descriptor_digest[DIGEST_LEN];
-
- char identity_digest[DIGEST_LEN];
-
- time_t published_on;
-
- char extra_info_digest[DIGEST_LEN];
-
- download_status_t ei_dl_status;
-
- saved_location_t saved_location ;
-
- off_t saved_offset;
-
- unsigned int do_not_cache : 1;
-
- unsigned int is_extrainfo : 1;
- } signed_descriptor_t;
- typedef struct {
- signed_descriptor_t cache_info;
- char *address;
- char *nickname;
- uint32_t addr;
- uint16_t or_port;
- uint16_t dir_port;
- crypto_pk_env_t *onion_pkey;
- crypto_pk_env_t *identity_pkey;
- char *platform;
-
- uint32_t bandwidthrate;
- uint32_t bandwidthburst;
-
- uint32_t bandwidthcapacity;
- addr_policy_t *exit_policy;
- long uptime;
- smartlist_t *declared_family;
- char *contact_info;
- unsigned int is_hibernating:1;
- unsigned int has_old_dnsworkers:1;
- unsigned int caches_extra_info:1;
-
- unsigned int is_running:1;
- unsigned int is_valid:1;
- unsigned int is_named:1;
- unsigned int is_fast:1;
- unsigned int is_stable:1;
- unsigned int is_possible_guard:1;
- unsigned int is_exit:1;
- unsigned int is_bad_exit:1;
- #define ROUTER_PURPOSE_GENERAL 0
- #define ROUTER_PURPOSE_CONTROLLER 1
- #define ROUTER_PURPOSE_BRIDGE 1
-
- uint8_t purpose;
-
-
- time_t last_reachable;
-
- time_t testing_since;
-
- int num_unreachable_notifications;
-
- int routerlist_index;
- } routerinfo_t;
- #define EXTRAINFO_PURPOSE_GENERAL -1
- typedef struct extrainfo_t {
- signed_descriptor_t cache_info;
-
- char nickname[MAX_NICKNAME_LEN+1];
-
- unsigned int bad_sig : 1;
-
- char *pending_sig;
-
- size_t pending_sig_len;
- } extrainfo_t;
- typedef struct routerstatus_t {
- time_t published_on;
- char nickname[MAX_NICKNAME_LEN+1];
- char identity_digest[DIGEST_LEN];
- char descriptor_digest[DIGEST_LEN];
- uint32_t addr;
- uint16_t or_port;
- uint16_t dir_port;
- unsigned int is_authority:1;
- unsigned int is_exit:1;
- unsigned int is_stable:1;
- unsigned int is_fast:1;
- unsigned int is_running:1;
- unsigned int is_named:1;
- unsigned int is_valid:1;
- unsigned int is_v2_dir:1;
- unsigned int is_possible_guard:1;
- unsigned int is_bad_exit:1;
- unsigned int is_bad_directory:1;
-
- unsigned int version_known:1;
-
- unsigned int version_supports_begindir:1;
-
- unsigned int version_supports_extrainfo_upload:1;
-
- unsigned int need_to_mirror:1;
- } routerstatus_t;
- typedef struct local_routerstatus_t {
-
- routerstatus_t status;
- time_t last_dir_503_at;
- download_status_t dl_status;
- unsigned int name_lookup_warned:1;
- } local_routerstatus_t;
- #define MAX_ROUTERDESC_DOWNLOAD_FAILURES 8
- typedef struct networkstatus_t {
-
- time_t received_on;
-
- char networkstatus_digest[DIGEST_LEN];
- unsigned int is_recent;
-
- time_t published_on;
- char *source_address;
- uint32_t source_addr;
- uint16_t source_dirport;
- unsigned int binds_names:1;
- unsigned int recommends_versions:1;
- unsigned int lists_bad_exits:1;
-
- unsigned int lists_bad_directories:1;
- char identity_digest[DIGEST_LEN];
- char *contact;
- crypto_pk_env_t *signing_key;
- char *client_versions;
- char *server_versions;
- smartlist_t *entries;
- } networkstatus_t;
- typedef struct vote_routerstatus_t {
- routerstatus_t status;
- uint64_t flags;
- char *version;
- } vote_routerstatus_t;
- typedef struct networkstatus_voter_info_t {
- char *nickname;
- char identity_digest[DIGEST_LEN];
- char *address;
- uint32_t addr;
- uint16_t dir_port;
- uint16_t or_port;
- char *contact;
- char vote_digest[DIGEST_LEN];
- char signing_key_digest[DIGEST_LEN];
- char *signature;
- int signature_len;
- unsigned int bad_signature : 1;
- unsigned int good_signature : 1;
- } networkstatus_voter_info_t;
- typedef struct networkstatus_vote_t {
- int is_vote;
- time_t published;
- time_t valid_after;
- time_t fresh_until;
- time_t valid_until;
- int vote_seconds;
- int dist_seconds;
- char *client_versions;
- char *server_versions;
- smartlist_t *known_flags;
- smartlist_t *voters;
- struct authority_cert_t *cert;
- char networkstatus_digest[DIGEST_LEN];
- smartlist_t *routerstatus_list;
- } networkstatus_vote_t;
- typedef struct ns_detached_signatures_t {
- time_t valid_after;
- time_t fresh_until;
- time_t valid_until;
- char networkstatus_digest[DIGEST_LEN];
- smartlist_t *signatures;
- } ns_detached_signatures_t;
- typedef struct {
-
- struct digest_ri_map_t *identity_map;
-
- struct digest_sd_map_t *desc_digest_map;
-
- struct digest_ei_map_t *extra_info_map;
-
- struct digest_sd_map_t *desc_by_eid_map;
-
- smartlist_t *routers;
-
- smartlist_t *old_routers;
-
- tor_mmap_t *mmap_descriptors;
-
- tor_mmap_t *mmap_extrainfo;
- } routerlist_t;
- typedef struct extend_info_t {
- char nickname[MAX_HEX_NICKNAME_LEN+1];
- char identity_digest[DIGEST_LEN];
- uint16_t port;
- uint32_t addr;
- crypto_pk_env_t *onion_key;
- } extend_info_t;
- typedef struct authority_cert_t {
- signed_descriptor_t cache_info;
- crypto_pk_env_t *identity_key;
- crypto_pk_env_t *signing_key;
- char signing_key_digest[DIGEST_LEN];
- time_t expires;
- } authority_cert_t;
- typedef enum {
- NO_AUTHORITY = 0,
- V1_AUTHORITY = 1 << 0,
- V2_AUTHORITY = 1 << 1,
- V3_AUTHORITY = 1 << 2,
- HIDSERV_AUTHORITY = 1 << 3,
- BRIDGE_AUTHORITY = 1 << 4,
- EXTRAINFO_CACHE = 1 << 5,
- } authority_type_t;
- #define CRYPT_PATH_MAGIC 0x70127012u
- typedef struct crypt_path_t {
- uint32_t magic;
-
-
- crypto_cipher_env_t *f_crypto;
-
- crypto_cipher_env_t *b_crypto;
-
- crypto_digest_env_t *f_digest;
-
- crypto_digest_env_t *b_digest;
-
- crypto_dh_env_t *dh_handshake_state;
-
- char fast_handshake_state[DIGEST_LEN];
-
- char handshake_digest[DIGEST_LEN];
-
- extend_info_t *extend_info;
-
- uint8_t state;
- #define CPATH_STATE_CLOSED 0
- #define CPATH_STATE_AWAITING_KEYS 1
- #define CPATH_STATE_OPEN 2
- struct crypt_path_t *next;
- struct crypt_path_t *prev;
- int package_window;
- int deliver_window;
- } crypt_path_t;
- #define CPATH_KEY_MATERIAL_LEN (20*2+16*2)
- #define DH_KEY_LEN DH_BYTES
- #define ONIONSKIN_CHALLENGE_LEN (PKCS1_OAEP_PADDING_OVERHEAD+\
- CIPHER_KEY_LEN+\
- DH_KEY_LEN)
- #define ONIONSKIN_REPLY_LEN (DH_KEY_LEN+DIGEST_LEN)
- #define REND_COOKIE_LEN DIGEST_LEN
- typedef struct {
-
- int desired_path_len;
-
- extend_info_t *chosen_exit;
-
- int need_uptime;
-
- int need_capacity;
-
- int is_internal;
-
- int onehop_tunnel;
-
- crypt_path_t *pending_final_cpath;
-
- int failure_count;
-
- time_t expiry_time;
- } cpath_build_state_t;
- #define ORIGIN_CIRCUIT_MAGIC 0x35315243u
- #define OR_CIRCUIT_MAGIC 0x98ABC04Fu
- typedef uint16_t circid_t;
- typedef struct circuit_t {
- uint32_t magic;
-
- cell_queue_t n_conn_cells;
-
- or_connection_t *n_conn;
-
- char n_conn_id_digest[DIGEST_LEN];
-
- uint16_t n_circ_id;
-
- uint16_t n_port;
-
- uint32_t n_addr;
-
- unsigned int streams_blocked_on_n_conn : 1;
-
- unsigned int streams_blocked_on_p_conn : 1;
- uint8_t state;
- uint8_t purpose;
-
- int package_window;
-
- int deliver_window;
-
- char *onionskin;
- time_t timestamp_created;
- time_t timestamp_dirty;
- uint16_t marked_for_close;
- const char *marked_for_close_file;
-
- struct circuit_t *next_active_on_n_conn;
-
- struct circuit_t *prev_active_on_n_conn;
- struct circuit_t *next;
- } circuit_t;
- typedef struct origin_circuit_t {
- circuit_t _base;
-
- edge_connection_t *p_streams;
-
- cpath_build_state_t *build_state;
-
- crypt_path_t *cpath;
-
- char rend_pk_digest[DIGEST_LEN];
-
- char rend_cookie[REND_COOKIE_LEN];
-
- char rend_query[REND_SERVICE_ID_LEN+1];
-
- uint16_t next_stream_id;
-
-
- uint32_t global_identifier;
- } origin_circuit_t;
- typedef struct or_circuit_t {
- circuit_t _base;
-
- struct circuit_t *next_active_on_p_conn;
-
- struct circuit_t *prev_active_on_p_conn;
-
- circid_t p_circ_id;
-
- cell_queue_t p_conn_cells;
-
- or_connection_t *p_conn;
-
- edge_connection_t *n_streams;
-
- edge_connection_t *resolving_streams;
-
- crypto_cipher_env_t *p_crypto;
-
- crypto_cipher_env_t *n_crypto;
-
- crypto_digest_env_t *p_digest;
-
- crypto_digest_env_t *n_digest;
-
- struct or_circuit_t *rend_splice;
- #if REND_COOKIE_LEN >= DIGEST_LEN
- #define REND_TOKEN_LEN REND_COOKIE_LEN
- #else
- #define REND_TOKEN_LEN DIGEST_LEN
- #endif
-
- char rend_token[REND_TOKEN_LEN];
-
- char handshake_digest[DIGEST_LEN];
-
- unsigned int is_first_hop : 1;
- } or_circuit_t;
- #define TO_CIRCUIT(x) (&((x)->_base))
- static or_circuit_t *TO_OR_CIRCUIT(circuit_t *);
- static origin_circuit_t *TO_ORIGIN_CIRCUIT(circuit_t *);
- static INLINE or_circuit_t *TO_OR_CIRCUIT(circuit_t *x)
- {
- tor_assert(x->magic == OR_CIRCUIT_MAGIC);
- return DOWNCAST(or_circuit_t, x);
- }
- static INLINE origin_circuit_t *TO_ORIGIN_CIRCUIT(circuit_t *x)
- {
- tor_assert(x->magic == ORIGIN_CIRCUIT_MAGIC);
- return DOWNCAST(origin_circuit_t, x);
- }
- #define ALLOW_INVALID_ENTRY 1
- #define ALLOW_INVALID_EXIT 2
- #define ALLOW_INVALID_MIDDLE 4
- #define ALLOW_INVALID_RENDEZVOUS 8
- #define ALLOW_INVALID_INTRODUCTION 16
- typedef struct exit_redirect_t {
-
- uint32_t addr;
- uint16_t port_min;
- uint16_t port_max;
- maskbits_t maskbits;
- uint32_t addr_dest;
- uint16_t port_dest;
- unsigned is_redirect:1;
- } exit_redirect_t;
- #define MIN_CONSTRAINED_TCP_BUFFER 2048
- #define MAX_CONSTRAINED_TCP_BUFFER 262144
- typedef struct config_line_t {
- char *key;
- char *value;
- struct config_line_t *next;
- } config_line_t;
- typedef struct {
- uint32_t _magic;
-
- enum {
- CMD_RUN_TOR=0, CMD_LIST_FINGERPRINT, CMD_HASH_PASSWORD,
- CMD_VERIFY_CONFIG, CMD_RUN_UNITTESTS
- } command;
- const char *command_arg;
- config_line_t *Logs;
- char *DebugLogFile;
- char *DataDirectory;
- char *Nickname;
- char *Address;
- char *PidFile;
- char *ExitNodes;
- char *EntryNodes;
- int StrictExitNodes;
- int StrictEntryNodes;
- char *ExcludeNodes;
- char *RendNodes;
- char *RendExcludeNodes;
-
- smartlist_t *AllowInvalidNodes;
- int _AllowInvalid;
- config_line_t *ExitPolicy;
- int ExitPolicyRejectPrivate;
- config_line_t *SocksPolicy;
- config_line_t *DirPolicy;
-
- config_line_t *SocksListenAddress;
-
- config_line_t *TransListenAddress;
-
- config_line_t *NatdListenAddress;
-
- config_line_t *DNSListenAddress;
-
- config_line_t *ORListenAddress;
-
- config_line_t *DirListenAddress;
-
- config_line_t *ControlListenAddress;
-
- char *OutboundBindAddress;
-
- config_line_t *RecommendedVersions;
- config_line_t *RecommendedClientVersions;
- config_line_t *RecommendedServerVersions;
-
- int DirAllowPrivateAddresses;
- char *User;
- char *Group;
- int ORPort;
- int SocksPort;
-
- int TransPort;
- int NatdPort;
- int ControlPort;
- config_line_t *ControlSocket;
- int DirPort;
- int DNSPort;
- int AssumeReachable;
- int AuthoritativeDir;
- int V1AuthoritativeDir;
- int V2AuthoritativeDir;
- int V3AuthoritativeDir;
- int HSAuthoritativeDir;
- int HSAuthorityRecordStats;
- int NamingAuthoritativeDir;
- int VersioningAuthoritativeDir;
- int BridgeAuthoritativeDir;
- int UseBridges;
- config_line_t *Bridges;
-
- int UpdateBridgesFromAuthority;
- int AvoidDiskWrites;
- int ClientOnly;
-
- int NoPublish;
-
- smartlist_t *PublishServerDescriptor;
-
- authority_type_t _PublishServerDescriptor;
-
- int PublishHidServDescriptors;
- int FetchServerDescriptors;
- int FetchHidServDescriptors;
- int FetchUselessDescriptors;
- int AllDirActionsPrivate;
- int ConnLimit;
- int _ConnLimit;
- int RunAsDaemon;
- int FascistFirewall;
- smartlist_t *FirewallPorts;
- config_line_t *ReachableAddresses;
- config_line_t *ReachableORAddresses;
- config_line_t *ReachableDirAddresses;
- int ConstrainedSockets;
- uint64_t ConstrainedSockSize;
-
- smartlist_t *LongLivedPorts;
-
- smartlist_t *TrackHostExits;
- int TrackHostExitsExpire;
- config_line_t *AddressMap;
- int AutomapHostsOnResolve;
- smartlist_t *AutomapHostsSuffixes;
- int RendPostPeriod;
- int KeepalivePeriod;
- int SocksTimeout;
- int CircuitBuildTimeout;
- int CircuitIdleTimeout;
- int MaxOnionsPending;
- int NewCircuitPeriod;
- int MaxCircuitDirtiness;
- uint64_t BandwidthRate;
- uint64_t BandwidthBurst;
- uint64_t MaxAdvertisedBandwidth;
- uint64_t RelayBandwidthRate;
- uint64_t RelayBandwidthBurst;
- int NumCpus;
- int RunTesting;
- char *TestVia;
- config_line_t *RendConfigLines;
- char *ContactInfo;
- char *HttpProxy;
- uint32_t HttpProxyAddr;
- uint16_t HttpProxyPort;
- char *HttpProxyAuthenticator;
- char *HttpsProxy;
- uint32_t HttpsProxyAddr;
- uint16_t HttpsProxyPort;
- char *HttpsProxyAuthenticator;
- config_line_t *DirServers;
- char *MyFamily;
- config_line_t *NodeFamilies;
- config_line_t *RedirectExit;
- smartlist_t *RedirectExitList;
- config_line_t *AuthDirBadExit;
- config_line_t *AuthDirReject;
- config_line_t *AuthDirInvalid;
- int AuthDirListBadExits;
- int AuthDirRejectUnlisted;
- char *AccountingStart;
- uint64_t AccountingMax;
- char *HashedControlPassword;
- int CookieAuthentication;
- int LeaveStreamsUnattached;
- int DisablePredictedCircuits;
- int ShutdownWaitLength;
- int SafeLogging;
- int SafeSocks;
- #define LOG_PROTOCOL_WARN (get_options()->ProtocolWarnings ? \
- LOG_WARN : LOG_INFO)
- int ProtocolWarnings;
- int TestSocks;
- int HardwareAccel;
- int UseEntryGuards;
- int NumEntryGuards;
- int RephistTrackTime;
- int FastFirstHopPK;
- addr_policy_t *reachable_addr_policy;
- char *VirtualAddrNetwork;
- int ServerDNSSearchDomains;
- int ServerDNSDetectHijacking;
- char *ServerDNSResolvConfFile;
- smartlist_t *ServerDNSTestAddresses;
- int EnforceDistinctSubnets;
- int TunnelDirConns;
- int PreferTunneledDirConns;
- int AllowNonRFC953Hostnames;
-
- int ServerDNSAllowNonRFC953Hostnames;
-
- int DownloadExtraInfo;
- } or_options_t;
- typedef struct {
- uint32_t _magic;
-
- time_t next_write;
-
- time_t LastWritten;
-
- time_t AccountingIntervalStart;
- uint64_t AccountingBytesReadInInterval;
- uint64_t AccountingBytesWrittenInInterval;
- int AccountingSecondsActive;
- uint64_t AccountingExpectedUsage;
-
- config_line_t *EntryGuards;
-
- time_t BWHistoryReadEnds;
- int BWHistoryReadInterval;
- smartlist_t *BWHistoryReadValues;
- time_t BWHistoryWriteEnds;
- int BWHistoryWriteInterval;
- smartlist_t *BWHistoryWriteValues;
-
- char *TorVersion;
-
- config_line_t *ExtraLines;
-
- time_t LastRotatedOnionKey;
- } or_state_t;
- static INLINE void or_state_mark_dirty(or_state_t *state, time_t when)
- {
- if (state->next_write > when)
- state->next_write = when;
- }
- #define MAX_SOCKS_REPLY_LEN 1024
- #define MAX_SOCKS_ADDR_LEN 256
- #define SOCKS_COMMAND_CONNECT 0x01
- #define SOCKS_COMMAND_RESOLVE 0xF0
- #define SOCKS_COMMAND_RESOLVE_PTR 0xF1
- #define SOCKS_COMMAND_CONNECT_DIR 0xF2
- #define SOCKS_COMMAND_IS_CONNECT(c) ((c)==SOCKS_COMMAND_CONNECT || \
- (c)==SOCKS_COMMAND_CONNECT_DIR)
- #define SOCKS_COMMAND_IS_RESOLVE(c) ((c)==SOCKS_COMMAND_RESOLVE || \
- (c)==SOCKS_COMMAND_RESOLVE_PTR)
- struct socks_request_t {
-
- char socks_version;
- int command;
- size_t replylen;
- char reply[MAX_SOCKS_REPLY_LEN];
- char address[MAX_SOCKS_ADDR_LEN];
- uint16_t port;
- unsigned has_finished : 1;
- };
- buf_t *buf_new(void);
- buf_t *buf_new_with_capacity(size_t size);
- void buf_free(buf_t *buf);
- void buf_clear(buf_t *buf);
- void buf_shrink(buf_t *buf);
- void buf_shrink_freelists(int free_all);
- void buf_dump_freelist_sizes(int severity);
- size_t buf_datalen(const buf_t *buf);
- size_t buf_capacity(const buf_t *buf);
- const char *_buf_peek_raw_buffer(const buf_t *buf);
- int read_to_buf(int s, size_t at_most, buf_t *buf, int *reached_eof);
- int read_to_buf_tls(tor_tls_t *tls, size_t at_most, buf_t *buf);
- int flush_buf(int s, buf_t *buf, size_t sz, size_t *buf_flushlen);
- int flush_buf_tls(tor_tls_t *tls, buf_t *buf, size_t sz, size_t *buf_flushlen);
- int write_to_buf(const char *string, size_t string_len, buf_t *buf);
- int write_to_buf_zlib(buf_t *buf, tor_zlib_state_t *state,
- const char *data, size_t data_len, int done);
- int move_buf_to_buf(buf_t *buf_out, buf_t *buf_in, size_t *buf_flushlen);
- int fetch_from_buf(char *string, size_t string_len, buf_t *buf);
- int fetch_from_buf_http(buf_t *buf,
- char **headers_out, size_t max_headerlen,
- char **body_out, size_t *body_used, size_t max_bodylen,
- int force_complete);
- int fetch_from_buf_socks(buf_t *buf, socks_request_t *req,
- int log_sockstype, int safe_socks);
- int fetch_from_buf_line(buf_t *buf, char *data_out, size_t *data_len);
- int fetch_from_buf_line_lf(buf_t *buf, char *data_out, size_t *data_len);
- int peek_buf_has_control0_command(buf_t *buf);
- void assert_buf_ok(buf_t *buf);
- char *circuit_list_path(origin_circuit_t *circ, int verbose);
- char *circuit_list_path_for_controller(origin_circuit_t *circ);
- void circuit_log_path(int severity, unsigned int domain,
- origin_circuit_t *circ);
- void circuit_rep_hist_note_result(origin_circuit_t *circ);
- origin_circuit_t *origin_circuit_init(uint8_t purpose, int onehop_tunnel,
- int need_uptime,
- int need_capacity, int internal);
- origin_circuit_t *circuit_establish_circuit(uint8_t purpose,
- int onehop_tunnel, extend_info_t *exit,
- int need_uptime, int need_capacity,
- int internal);
- int circuit_handle_first_hop(origin_circuit_t *circ);
- void circuit_n_conn_done(or_connection_t *or_conn, int status);
- int inform_testing_reachability(void);
- int circuit_send_next_onion_skin(origin_circuit_t *circ);
- void circuit_note_clock_jumped(int seconds_elapsed);
- int circuit_extend(cell_t *cell, circuit_t *circ);
- int circuit_init_cpath_crypto(crypt_path_t *cpath, const char *key_data,
- int reverse);
- int circuit_finish_handshake(origin_circuit_t *circ, uint8_t cell_type,
- const char *reply);
- int circuit_truncated(origin_circuit_t *circ, crypt_path_t *layer);
- int onionskin_answer(or_circuit_t *circ, uint8_t cell_type,
- const char *payload, const char *keys);
- int circuit_all_predicted_ports_handled(time_t now, int *need_uptime,
- int *need_capacity);
- int circuit_append_new_exit(origin_circuit_t *circ, extend_info_t *info);
- int circuit_extend_to_new_exit(origin_circuit_t *circ, extend_info_t *info);
- void onion_append_to_cpath(crypt_path_t **head_ptr, crypt_path_t *new_hop);
- extend_info_t *extend_info_alloc(const char *nickname, const char *digest,
- crypto_pk_env_t *onion_key,
- uint32_t addr, uint16_t port);
- extend_info_t *extend_info_from_router(routerinfo_t *r);
- extend_info_t *extend_info_dup(extend_info_t *info);
- void extend_info_free(extend_info_t *info);
- routerinfo_t *build_state_get_exit_router(cpath_build_state_t *state);
- const char *build_state_get_exit_nickname(cpath_build_state_t *state);
- void entry_guards_compute_status(void);
- int entry_guard_register_connect_status(const char *digest, int succeeded,
- time_t now);
- void entry_nodes_should_be_added(void);
- routerinfo_t *choose_random_entry(cpath_build_state_t *state);
- int entry_guards_parse_state(or_state_t *state, int set, char **msg);
- void entry_guards_update_state(or_state_t *state);
- int getinfo_helper_entry_guards(control_connection_t *conn,
- const char *question, char **answer);
- void clear_bridge_list(void);
- int routerinfo_is_a_configured_bridge(routerinfo_t *ri);
- void bridge_add_from_config(uint32_t addr, uint16_t port, char *digest);
- void fetch_bridge_descriptors(time_t now);
- void learned_bridge_descriptor(routerinfo_t *ri);
- int any_bridge_descriptors_known(void);
- int bridges_should_be_retried(void);
- void bridges_retry_all(void);
- void entry_guards_free_all(void);
- circuit_t * _circuit_get_global_list(void);
- const char *circuit_state_to_string(int state);
- void circuit_dump_by_conn(connection_t *conn, int severity);
- void circuit_set_p_circid_orconn(or_circuit_t *circ, uint16_t id,
- or_connection_t *conn);
- void circuit_set_n_circid_orconn(circuit_t *circ, uint16_t id,
- or_connection_t *conn);
- void circuit_set_state(circuit_t *circ, int state);
- void circuit_close_all_marked(void);
- origin_circuit_t *origin_circuit_new(void);
- or_circuit_t *or_circuit_new(uint16_t p_circ_id, or_connection_t *p_conn);
- circuit_t *circuit_get_by_circid_orconn(uint16_t circ_id,
- or_connection_t *conn);
- circuit_t *circuit_get_by_edge_conn(edge_connection_t *conn);
- void circuit_unlink_all_from_or_conn(or_connection_t *conn, int reason);
- origin_circuit_t *circuit_get_by_global_id(uint32_t id);
- origin_circuit_t *circuit_get_by_rend_query_and_purpose(const char *rend_query,
- uint8_t purpose);
- origin_circuit_t *circuit_get_next_by_pk_and_purpose(origin_circuit_t *start,
- const char *digest, uint8_t purpose);
- or_circuit_t *circuit_get_rendezvous(const char *cookie);
- or_circuit_t *circuit_get_intro_point(const char *digest);
- origin_circuit_t *circuit_find_to_cannibalize(uint8_t purpose,
- extend_info_t *info,
- int need_uptime,
- int need_capacity, int internal);
- void circuit_mark_all_unused_circs(void);
- void circuit_expire_all_dirty_circs(void);
- void _circuit_mark_for_close(circuit_t *circ, int reason,
- int line, const char *file);
- int circuit_get_cpath_len(origin_circuit_t *circ);
- crypt_path_t *circuit_get_cpath_hop(origin_circuit_t *circ, int hopnum);
- void circuit_get_all_pending_on_or_conn(smartlist_t *out,
- or_connection_t *or_conn);
- int circuit_count_pending_on_or_conn(or_connection_t *or_conn);
- #define circuit_mark_for_close(c, reason) \
- _circuit_mark_for_close((c), (reason), __LINE__, _SHORT_FILE_)
- void assert_cpath_layer_ok(const crypt_path_t *cp);
- void assert_circuit_ok(const circuit_t *c);
- void circuit_free_all(void);
- void circuit_expire_building(time_t now);
- void circuit_remove_handled_ports(smartlist_t *needed_ports);
- int circuit_stream_is_being_handled(edge_connection_t *conn, uint16_t port,
- int min);
- void circuit_build_needed_circs(time_t now);
- void circuit_detach_stream(circuit_t *circ, edge_connection_t *conn);
- void reset_bandwidth_test(void);
- int circuit_enough_testing_circs(void);
- void circuit_has_opened(origin_circuit_t *circ);
- void circuit_build_failed(origin_circuit_t *circ);
- origin_circuit_t *circuit_launch_by_nickname(uint8_t purpose,
- int onehop_tunnel,
- const char *exit_nickname,
- int need_uptime, int need_capacity,
- int is_internal);
- origin_circuit_t *circuit_launch_by_extend_info(uint8_t purpose,
- int onehop_tunnel,
- extend_info_t *info,
- int need_uptime, int need_capacity,
- int is_internal);
- origin_circuit_t *circuit_launch_by_router(uint8_t purpose,
- int onehop_tunnel,
- routerinfo_t *exit,
- int need_uptime, int need_capacity,
- int is_internal);
- void circuit_reset_failure_count(int timeout);
- int connection_ap_handshake_attach_chosen_circuit(edge_connection_t *conn,
- origin_circuit_t *circ,
- crypt_path_t *cpath);
- int connection_ap_handshake_attach_circuit(edge_connection_t *conn);
- void command_process_cell(cell_t *cell, or_connection_t *conn);
- extern uint64_t stats_n_padding_cells_processed;
- extern uint64_t stats_n_create_cells_processed;
- extern uint64_t stats_n_created_cells_processed;
- extern uint64_t stats_n_relay_cells_processed;
- extern uint64_t stats_n_destroy_cells_processed;
- or_options_t *get_options(void);
- int set_options(or_options_t *new_val, char **msg);
- void config_free_all(void);
- const char *safe_str(const char *address);
- const char *escaped_safe_str(const char *address);
- const char *get_version(void);
- int config_get_lines(char *string, config_line_t **result);
- void config_free_lines(config_line_t *front);
- int options_trial_assign(config_line_t *list, int use_defaults,
- int clear_first, char **msg);
- int resolve_my_address(int warn_severity, or_options_t *options,
- uint32_t *addr, char **hostname_out);
- int is_local_IP(uint32_t ip) ATTR_PURE;
- void options_init(or_options_t *options);
- int options_init_from_torrc(int argc, char **argv);
- int options_init_logs(or_options_t *options, int validate_only);
- int option_is_recognized(const char *key);
- const char *option_get_canonical_name(const char *key);
- config_line_t *option_get_assignment(or_options_t *options,
- const char *key);
- char *options_dump(or_options_t *options, int minimal);
- int options_save_current(void);
- const char *get_torrc_fname(void);
- or_state_t *get_or_state(void);
- int or_state_load(void);
- int or_state_save(time_t now);
- int getinfo_helper_config(control_connection_t *conn,
- const char *question, char **answer);
- #ifdef CONFIG_PRIVATE
- or_options_t *options_new(void);
- #endif
- const char *conn_type_to_string(int type);
- const char *conn_state_to_string(int type, int state);
- connection_t *connection_new(int type, int socket_family);
- void connection_link_connections(connection_t *conn_a, connection_t *conn_b);
- void connection_unregister_events(connection_t *conn);
- void connection_free(connection_t *conn);
- void connection_free_all(void);
- void connection_about_to_close_connection(connection_t *conn);
- void connection_close_immediate(connection_t *conn);
- void _connection_mark_for_close(connection_t *conn,int line, const char *file);
- #define connection_mark_for_close(c) \
- _connection_mark_for_close((c), __LINE__, _SHORT_FILE_)
- void connection_expire_held_open(void);
- int connection_connect(connection_t *conn, const char *address, uint32_t addr,
- uint16_t port);
- int retry_all_listeners(smartlist_t *replaced_conns,
- smartlist_t *new_conns);
- int connection_bucket_write_limit(connection_t *conn);
- int global_write_bucket_low(connection_t *conn, size_t attempt, int priority);
- void connection_bucket_init(void);
- void connection_bucket_refill(int seconds_elapsed);
- int connection_handle_read(connection_t *conn);
- int connection_fetch_from_buf(char *string, size_t len, connection_t *conn);
- int connection_wants_to_flush(connection_t *conn);
- int connection_outbuf_too_full(connection_t *conn);
- int connection_handle_write(connection_t *conn, int force);
- void _connection_write_to_buf_impl(const char *string, size_t len,
- connection_t *conn, int zlib);
- static void connection_write_to_buf(const char *string, size_t len,
- connection_t *conn);
- static void connection_write_to_buf_zlib(const char *string, size_t len,
- dir_connection_t *conn, int done);
- static INLINE void
- connection_write_to_buf(const char *string, size_t len, connection_t *conn)
- {
- _connection_write_to_buf_impl(string, len, conn, 0);
- }
- static INLINE void
- connection_write_to_buf_zlib(const char *string, size_t len,
- dir_connection_t *conn, int done)
- {
- _connection_write_to_buf_impl(string, len, TO_CONN(conn), done ? -1 : 1);
- }
- or_connection_t *connection_or_exact_get_by_addr_port(uint32_t addr,
- uint16_t port);
- edge_connection_t *connection_get_by_global_id(uint32_t id);
- connection_t *connection_get_by_type(int type);
- connection_t *connection_get_by_type_purpose(int type, int purpose);
- connection_t *connection_get_by_type_addr_port_purpose(int type, uint32_t addr,
- uint16_t port, int purpose);
- connection_t *connection_get_by_type_state(int type, int state);
- connection_t *connection_get_by_type_state_lastwritten(int type, int state);
- connection_t *connection_get_by_type_state_rendquery(int type, int state,
- const char *rendquery);
- #define connection_speaks_cells(conn) ((conn)->type == CONN_TYPE_OR)
- int connection_is_listener(connection_t *conn);
- int connection_state_is_open(connection_t *conn);
- int connection_state_is_connecting(connection_t *conn);
- char *alloc_http_authenticator(const char *authenticator);
- void assert_connection_ok(connection_t *conn, time_t now);
- int connection_or_nonopen_was_started_here(or_connection_t *conn);
- void connection_dump_buffer_mem_stats(int severity);
- #define connection_mark_unattached_ap(conn, endreason) \
- _connection_mark_unattached_ap((conn), (endreason), __LINE__, _SHORT_FILE_)
- void _connection_mark_unattached_ap(edge_connection_t *conn, int endreason,
- int line, const char *file);
- int connection_edge_reached_eof(edge_connection_t *conn);
- int connection_edge_process_inbuf(edge_connection_t *conn,
- int package_partial);
- int connection_edge_destroy(uint16_t circ_id, edge_connection_t *conn);
- int connection_edge_end(edge_connection_t *conn, char reason);
- int connection_edge_end_errno(edge_connection_t *conn);
- int connection_edge_finished_flushing(edge_connection_t *conn);
- int connection_edge_finished_connecting(edge_connection_t *conn);
- int connection_ap_handshake_send_begin(edge_connection_t *ap_conn);
- int connection_ap_handshake_send_resolve(edge_connection_t *ap_conn);
- edge_connection_t *connection_ap_make_link(char *address, uint16_t port,
- const char *digest, int command);
- void connection_ap_handshake_socks_reply(edge_connection_t *conn, char *reply,
- size_t replylen,
- int endreason);
- void connection_ap_handshake_socks_resolved(edge_connection_t *conn,
- int answer_type,
- size_t answer_len,
- const char *answer,
- int ttl,
- time_t expires);
- int connection_exit_begin_conn(cell_t *cell, circuit_t *circ);
- int connection_exit_begin_resolve(cell_t *cell, or_circuit_t *circ);
- void connection_exit_connect(edge_connection_t *conn);
- int connection_edge_is_rendezvous_stream(edge_connection_t *conn);
- int connection_ap_can_use_exit(edge_connection_t *conn, routerinfo_t *exit);
- void connection_ap_expire_beginning(void);
- void connection_ap_attach_pending(void);
- void circuit_discard_optional_exit_enclaves(extend_info_t *info);
- int connection_ap_detach_retriable(edge_connection_t *conn,
- origin_circuit_t *circ,
- int reason);
- int connection_ap_process_transparent(edge_connection_t *conn);
- int address_is_invalid_destination(const char *address, int client);
- void addressmap_init(void);
- void addressmap_clean(time_t now);
- void addressmap_clear_configured(void);
- void addressmap_clear_transient(void);
- void addressmap_free_all(void);
- int addressmap_rewrite(char *address, size_t maxlen, time_t *expires_out);
- int addressmap_have_mapping(const char *address);
- void addressmap_register(const char *address, char *new_address,
- time_t expires);
- int parse_virtual_addr_network(const char *val, int validate_only,
- char **msg);
- int client_dns_incr_failures(const char *address);
- void client_dns_clear_failures(const char *address);
- void client_dns_set_addressmap(const char *address, uint32_t val,
- const char *exitname, int ttl);
- int address_is_in_virtual_range(const char *addr);
- const char *addressmap_register_virtual_address(int type, char *new_address);
- void addressmap_get_mappings(smartlist_t *sl, time_t min_expires,
- time_t max_expires, int want_expiry);
- int connection_ap_handshake_rewrite_and_attach(edge_connection_t *conn,
- origin_circuit_t *circ,
- crypt_path_t *cpath);
- int hostname_is_noconnect_address(const char *address);
- void set_exit_redirects(smartlist_t *lst);
- typedef enum hostname_type_t {
- NORMAL_HOSTNAME, ONION_HOSTNAME, EXIT_HOSTNAME, BAD_HOSTNAME
- } hostname_type_t;
- hostname_type_t parse_extended_hostname(char *address);
- void connection_or_remove_from_identity_map(or_connection_t *conn);
- void connection_or_clear_identity_map(void);
- or_connection_t *connection_or_get_by_identity_digest(const char *digest);
- int connection_or_reached_eof(or_connection_t *conn);
- int connection_or_process_inbuf(or_connection_t *conn);
- int connection_or_flushed_some(or_connection_t *conn);
- int connection_or_finished_flushing(or_connection_t *conn);
- int connection_or_finished_connecting(or_connection_t *conn);
- or_connection_t *connection_or_connect(uint32_t addr, uint16_t port,
- const char *id_digest);
- int connection_tls_start_handshake(or_connection_t *conn, int receiving);
- int connection_tls_continue_handshake(or_connection_t *conn);
- void connection_or_write_cell_to_buf(const cell_t *cell,
- or_connection_t *conn);
- int connection_or_send_destroy(uint16_t circ_id, or_connection_t *conn,
- int reason);
- void cell_pack(packed_cell_t *dest, const cell_t *src);
- typedef enum circuit_status_event_t {
- CIRC_EVENT_LAUNCHED = 0,
- CIRC_EVENT_BUILT = 1,
- CIRC_EVENT_EXTENDED = 2,
- CIRC_EVENT_FAILED = 3,
- CIRC_EVENT_CLOSED = 4,
- } circuit_status_event_t;
- typedef enum stream_status_event_t {
- STREAM_EVENT_SENT_CONNECT = 0,
- STREAM_EVENT_SENT_RESOLVE = 1,
- STREAM_EVENT_SUCCEEDED = 2,
- STREAM_EVENT_FAILED = 3,
- STREAM_EVENT_CLOSED = 4,
- STREAM_EVENT_NEW = 5,
- STREAM_EVENT_NEW_RESOLVE = 6,
- STREAM_EVENT_FAILED_RETRIABLE = 7,
- STREAM_EVENT_REMAP = 8
- } stream_status_event_t;
- typedef enum or_conn_status_event_t {
- OR_CONN_EVENT_LAUNCHED = 0,
- OR_CONN_EVENT_CONNECTED = 1,
- OR_CONN_EVENT_FAILED = 2,
- OR_CONN_EVENT_CLOSED = 3,
- OR_CONN_EVENT_NEW = 4,
- } or_conn_status_event_t;
- void control_update_global_event_mask(void);
- void control_adjust_event_log_severity(void);
- #define CONN_LOG_PROTECT(conn, stmt) \
- STMT_BEGIN \
- int _log_conn_is_control = (conn && conn->type == CONN_TYPE_CONTROL); \
- if (_log_conn_is_control) \
- disable_control_logging(); \
- STMT_BEGIN stmt; STMT_END; \
- if (_log_conn_is_control) \
- enable_control_logging(); \
- STMT_END
- #define LOG_FN_CONN(conn, args) \
- CONN_LOG_PROTECT(conn, log_fn args)
- int connection_control_finished_flushing(control_connection_t *conn);
- int connection_control_reached_eof(control_connection_t *conn);
- int connection_control_process_inbuf(control_connection_t *conn);
- #define EVENT_AUTHDIR_NEWDESCS 0x000D
- int control_event_is_interesting(int event);
- int control_event_circuit_status(origin_circuit_t *circ,
- circuit_status_event_t e, int reason);
- int control_event_stream_status(edge_connection_t *conn,
- stream_status_event_t e,
- int reason);
- int control_tls_error_to_reason(int e);
- int control_event_or_conn_status(or_connection_t *conn,
- or_conn_status_event_t e, int reason);
- int control_event_bandwidth_used(uint32_t n_read, uint32_t n_written);
- int control_event_stream_bandwidth_used(void);
- void control_event_logmsg(int severity, unsigned int domain, const char *msg);
- int control_event_descriptors_changed(smartlist_t *routers);
- int control_event_address_mapped(const char *from, const char *to,
- time_t expires, const char *error);
- int control_event_or_authdir_new_descriptor(const char *action,
- const char *desc,
- size_t desclen,
- const char *msg);
- int control_event_my_descriptor_changed(void);
- int control_event_networkstatus_changed(smartlist_t *statuses);
- int control_event_networkstatus_changed_single(local_routerstatus_t *rs);
- int control_event_general_status(int severity, const char *format, ...)
- CHECK_PRINTF(2,3);
- int control_event_client_status(int severity, const char *format, ...)
- CHECK_PRINTF(2,3);
- int control_event_server_status(int severity, const char *format, ...)
- CHECK_PRINTF(2,3);
- int control_event_guard(const char *nickname, const char *digest,
- const char *status);
- int init_cookie_authentication(int enabled);
- int decode_hashed_password(char *buf, const char *hashed);
- void disable_control_logging(void);
- void enable_control_logging(void);
- #ifdef CONTROL_PRIVATE
- size_t write_escaped_data(const char *data, size_t len,
- int translate_newlines, char **out);
- size_t read_escaped_data(const char *data, size_t len,
- int translate_newlines, char **out);
- #endif
- void cpu_init(void);
- void cpuworkers_rotate(void);
- int connection_cpu_finished_flushing(connection_t *conn);
- int connection_cpu_reached_eof(connection_t *conn);
- int connection_cpu_process_inbuf(connection_t *conn);
- int assign_to_cpuworker(connection_t *cpuworker, uint8_t question_type,
- void *task);
- char *authority_type_to_string(authority_type_t auth);
- void directory_post_to_dirservers(uint8_t dir_purpose, uint8_t router_purpose,
- authority_type_t type, const char *payload,
- size_t payload_len, size_t extrainfo_len);
- void directory_get_from_dirserver(uint8_t dir_purpose, uint8_t router_purpose,
- const char *resource,
- int retry_if_no_servers);
- void directory_initiate_command_routerstatus(routerstatus_t *status,
- uint8_t dir_purpose,
- uint8_t router_purpose,
- int anonymized_connection,
- const char *resource,
- const char *payload,
- size_t payload_len);
- int parse_http_response(const char *headers, int *code, time_t *date,
- compress_method_t *compression, char **response);
- int connection_dir_reached_eof(dir_connection_t *conn);
- int connection_dir_process_inbuf(dir_connection_t *conn);
- int connection_dir_finished_flushing(dir_connection_t *conn);
- int connection_dir_finished_connecting(dir_connection_t *conn);
- void connection_dir_request_failed(dir_connection_t *conn);
- void directory_initiate_command(const char *address, uint32_t addr,
- uint16_t or_port, uint16_t dir_port,
- int supports_begindir, const char *digest,
- uint8_t dir_purpose, uint8_t router_purpose,
- int anonymized_connection,
- const char *resource,
- const char *payload, size_t payload_len);
- int dir_split_resource_into_fingerprints(const char *resource,
- smartlist_t *fp_out, int *compresseed_out,
- int decode_hex, int sort_uniq);
- char *directory_dump_request_log(void);
- int router_supports_extrainfo(const char *identity_digest, int is_authority);
- #define UNNAMED_ROUTER_NICKNAME "Unnamed"
- int connection_dirserv_flushed_some(dir_connection_t *conn);
- int dirserv_add_own_fingerprint(const char *nickname, crypto_pk_env_t *pk);
- int dirserv_load_fingerprint_file(void);
- void dirserv_free_fingerprint_list(void);
- const char *dirserv_get_nickname_by_digest(const char *digest);
- int dirserv_add_multiple_descriptors(const char *desc, uint8_t purpose,
- const char **msg);
- int dirserv_add_descriptor(routerinfo_t *ri, const char **msg);
- int getinfo_helper_dirserv_unregistered(control_connection_t *conn,
- const char *question, char **answer);
- void dirserv_free_descriptors(void);
- int dirserv_thinks_router_is_blatantly_unreachable(routerinfo_t *router,
- time_t now);
- int list_server_status(smartlist_t *routers, char **router_status_out,
- int for_controller);
- int dirserv_dump_directory_to_string(char **dir_out,
- crypto_pk_env_t *private_key,
- int complete);
- void directory_set_dirty(void);
- cached_dir_t *dirserv_get_directory(void);
- cached_dir_t *dirserv_get_runningrouters(void);
- void dirserv_set_cached_directory(const char *directory, time_t when,
- int is_running_routers);
- void dirserv_set_cached_networkstatus_v2(const char *directory,
- const char *identity,
- time_t published);
- void dirserv_clear_old_networkstatuses(time_t cutoff);
- void dirserv_clear_old_v1_info(time_t now);
- void dirserv_get_networkstatus_v2(smartlist_t *result, const char *key);
- void dirserv_get_networkstatus_v2_fingerprints(smartlist_t *result,
- const char *key);
- int dirserv_get_routerdesc_fingerprints(smartlist_t *fps_out, const char *key,
- const char **msg);
- int dirserv_get_routerdescs(smartlist_t *descs_out, const char *key,
- const char **msg);
- void dirserv_orconn_tls_done(const char *address,
- uint16_t or_port,
- const char *digest_rcvd,
- int as_advertised);
- void dirserv_test_reachability(int try_all);
- int authdir_wants_to_reject_router(routerinfo_t *ri, const char **msg,
- int complain);
- int dirserv_would_reject_router(routerstatus_t *rs);
- int dirserv_remove_old_statuses(smartlist_t *fps, time_t cutoff);
- size_t dirserv_estimate_data_size(smartlist_t *fps, int is_serverdescs,
- int compressed);
- int routerstatus_format_entry(char *buf, size_t buf_len,
- routerstatus_t *rs, const char *platform,
- int first_line_only);
- void dirserv_free_all(void);
- void cached_dir_decref(cached_dir_t *d);
- cached_dir_t *new_cached_dir(char *s, time_t published);
- cached_dir_t *generate_v3_networkstatus(void);
- #ifdef DIRSERV_PRIVATE
- char *
- format_networkstatus_vote(crypto_pk_env_t *private_key,
- networkstatus_vote_t *v3_ns);
- #endif
- void dirvote_free_all(void);
- void networkstatus_vote_free(networkstatus_vote_t *ns);
- char *networkstatus_compute_consensus(smartlist_t *votes,
- int total_authorities,
- crypto_pk_env_t *identity_key,
- crypto_pk_env_t *signing_key);
- networkstatus_voter_info_t *networkstatus_get_voter_by_id(
- networkstatus_vote_t *vote,
- const char *identity);
- int networkstatus_check_consensus_signature(networkstatus_vote_t *consensus);
- int networkstatus_add_consensus_signatures(networkstatus_vote_t *target,
- networkstatus_vote_t *src,
- char **new_signatures_out);
- int networkstatus_add_detached_signatures(networkstatus_vote_t *target,
- ns_detached_signatures_t *sigs,
- char **new_signatures_out);
- char *networkstatus_get_detached_signatures(networkstatus_vote_t *consensus);
- void ns_detached_signatures_free(ns_detached_signatures_t *s);
- void authority_cert_free(authority_cert_t *cert);
- authority_cert_t *authority_cert_dup(authority_cert_t *cert);
- typedef struct vote_timing_t {
- int vote_interval;
- int n_intervals_valid;
- int vote_delay;
- int dist_delay;
- } vote_timing_t;
- void dirvote_get_preferred_voting_intervals(vote_timing_t *timing_out);
- time_t dirvote_get_start_of_next_interval(time_t now, int interval);
- void dirvote_recalculate_timing(time_t now);
- void dirvote_perform_vote(void);
- void dirvote_clear_pending_votes(void);
- struct pending_vote_t * dirvote_add_vote(const char *vote_body,
- const char **msg_out);
- int dirvote_compute_consensus(void);
- int dirvote_add_signatures(const char *detached_signatures_body);
- #ifdef DIRVOTE_PRIVATE
- int networkstatus_check_voter_signature(networkstatus_vote_t *consensus,
- networkstatus_voter_info_t *voter,
- authority_cert_t *cert);
- #endif
- int dns_init(void);
- void dns_free_all(void);
- uint32_t dns_clip_ttl(uint32_t ttl);
- int dns_reset(void);
- void connection_dns_remove(edge_connection_t *conn);
- void assert_connection_edge_not_dns_pending(edge_connection_t *conn);
- void assert_all_pending_dns_resolves_ok(void);
- void dns_cancel_pending_resolve(const char *question);
- int dns_resolve(edge_connection_t *exitconn);
- void dns_launch_correctness_checks(void);
- int dns_seems_to_be_broken(void);
- void dns_reset_correctness_checks(void);
- void dnsserv_configure_listener(connection_t *conn);
- void dnsserv_close_listener(connection_t *conn);
- void dnsserv_resolved(edge_connection_t *conn,
- int answer_type,
- size_t answer_len,
- const char *answer,
- int ttl);
- void dnsserv_reject_request(edge_connection_t *conn);
- void dnsserv_launch_request(const char *name, int is_reverse);
- int accounting_parse_options(or_options_t *options, int validate_only);
- int accounting_is_enabled(or_options_t *options);
- void configure_accounting(time_t now);
- void accounting_run_housekeeping(time_t now);
- void accounting_add_bytes(size_t n_read, size_t n_written, int seconds);
- int accounting_record_bandwidth_usage(time_t now, or_state_t *state);
- void hibernate_begin_shutdown(void);
- int we_are_hibernating(void);
- void consider_hibernation(time_t now);
- int getinfo_helper_accounting(control_connection_t *conn,
- const char *question, char **answer);
- void accounting_set_bandwidth_usage_from_state(or_state_t *state);
- extern int has_completed_circuit;
- int connection_add(connection_t *conn);
- int connection_remove(connection_t *conn);
- int connection_in_array(connection_t *conn);
- void add_connection_to_closeable_list(connection_t *conn);
- int connection_is_on_closeable_list(connection_t *conn);
- smartlist_t *get_connection_array(void);
- void connection_watch_events(connection_t *conn, short events);
- int connection_is_reading(connection_t *conn);
- void connection_stop_reading(connection_t *conn);
- void connection_start_reading(connection_t *conn);
- int connection_is_writing(connection_t *conn);
- void connection_stop_writing(connection_t *conn);
- void connection_start_writing(connection_t *conn);
- void connection_stop_reading_from_linked_conn(connection_t *conn);
- void directory_all_unreachable(time_t now);
- void directory_info_has_arrived(time_t now, int from_cache);
- void ip_address_changed(int at_interface);
- void dns_servers_relaunch_checks(void);
- void control_signal_act(int the_signal);
- void handle_signals(int is_parent);
- void tor_cleanup(void);
- void tor_free_all(int postfork);
- int tor_main(int argc, char *argv[]);
- int onion_pending_add(or_circuit_t *circ);
- or_circuit_t *onion_next_task(void);
- void onion_pending_remove(or_circuit_t *circ);
- int onion_skin_create(crypto_pk_env_t *router_key,
- crypto_dh_env_t **handshake_state_out,
- char *onion_skin_out);
- int onion_skin_server_handshake(const char *onion_skin,
- crypto_pk_env_t *private_key,
- crypto_pk_env_t *prev_private_key,
- char *handshake_reply_out,
- char *key_out,
- size_t key_out_len);
- int onion_skin_client_handshake(crypto_dh_env_t *handshake_state,
- const char *handshake_reply,
- char *key_out,
- size_t key_out_len);
- int fast_server_handshake(const char *key_in,
- char *handshake_reply_out,
- char *key_out,
- size_t key_out_len);
- int fast_client_handshake(const char *handshake_state,
- const char *handshake_reply_out,
- char *key_out,
- size_t key_out_len);
- void clear_pending_onions(void);
- #define POLICY_BUF_LEN 52
- typedef enum {
- ADDR_POLICY_ACCEPTED=0,
- ADDR_POLICY_REJECTED=-1,
- ADDR_POLICY_PROBABLY_ACCEPTED=1,
- ADDR_POLICY_PROBABLY_REJECTED=2
- } addr_policy_result_t;
- int firewall_is_fascist_or(void);
- int fascist_firewall_allows_address_or(uint32_t addr, uint16_t port);
- int fascist_firewall_allows_address_dir(uint32_t addr, uint16_t port);
- int dir_policy_permits_address(uint32_t addr);
- int socks_policy_permits_address(uint32_t addr);
- int authdir_policy_permits_address(uint32_t addr, uint16_t port);
- int authdir_policy_valid_address(uint32_t addr, uint16_t port);
- int authdir_policy_badexit_address(uint32_t addr, uint16_t port);
- int validate_addr_policies(or_options_t *options, char **msg);
- void policies_parse_from_options(or_options_t *options);
- int cmp_addr_policies(addr_policy_t *a, addr_policy_t *b);
- addr_policy_result_t compare_addr_to_addr_policy(uint32_t addr,
- uint16_t port, addr_policy_t *policy);
- int policies_parse_exit_policy(config_line_t *cfg,
- addr_policy_t **dest,
- int rejectprivate);
- int exit_policy_is_general_exit(addr_policy_t *policy);
- int policy_is_reject_star(addr_policy_t *policy);
- int getinfo_helper_policies(control_connection_t *conn,
- const char *question, char **answer);
- int policy_write_item(char *buf, size_t buflen, addr_policy_t *policy);
- void addr_policy_free(addr_policy_t *p);
- void policies_free_all(void);
- extern uint64_t stats_n_relay_cells_relayed;
- extern uint64_t stats_n_relay_cells_delivered;
- int circuit_receive_relay_cell(cell_t *cell, circuit_t *circ,
- int cell_direction);
- void relay_header_pack(char *dest, const relay_header_t *src);
- void relay_header_unpack(relay_header_t *dest, const char *src);
- int relay_send_command_from_edge(uint16_t stream_id, circuit_t *circ,
- int relay_command, const char *payload,
- size_t payload_len, crypt_path_t *cpath_layer);
- int connection_edge_send_command(edge_connection_t *fromconn,
- int relay_command, const char *payload,
- size_t payload_len);
- int connection_edge_package_raw_inbuf(edge_connection_t *conn,
- int package_partial);
- void connection_edge_consider_sending_sendme(edge_connection_t *conn);
- socks5_reply_status_t connection_edge_end_reason_socks5_response(int reason);
- int errno_to_end_reason(int e);
- extern uint64_t stats_n_data_cells_packaged;
- extern uint64_t stats_n_data_bytes_packaged;
- extern uint64_t stats_n_data_cells_received;
- extern uint64_t stats_n_data_bytes_received;
- void init_cell_pool(void);
- void free_cell_pool(void);
- void clean_cell_pool(void);
- void dump_cell_pool_usage(int severity);
- void cell_queue_clear(cell_queue_t *queue);
- void cell_queue_append(cell_queue_t *queue, packed_cell_t *cell);
- void cell_queue_append_packed_copy(cell_queue_t *queue, const cell_t *cell);
- void append_cell_to_circuit_queue(circuit_t *circ, or_connection_t *orconn,
- cell_t *cell, int direction);
- void connection_or_unlink_all_active_circs(or_connection_t *conn);
- int connection_or_flush_from_first_active_circuit(or_connection_t *conn,
- int max);
- void assert_active_circuits_ok(or_connection_t *orconn);
- void make_circuit_inactive_on_conn(circuit_t *circ, or_connection_t *conn);
- void make_circuit_active_on_conn(circuit_t *circ, or_connection_t *conn);
- void circuit_clear_cell_queue(circuit_t *circ, or_connection_t *orconn);
- void rep_hist_init(void);
- void rep_hist_note_connect_failed(const char* nickname, time_t when);
- void rep_hist_note_connect_succeeded(const char* nickname, time_t when);
- void rep_hist_note_disconnect(const char* nickname, time_t when);
- void rep_hist_note_connection_died(const char* nickname, time_t when);
- void rep_hist_note_extend_succeeded(const char *from_name,
- const char *to_name);
- void rep_hist_note_extend_failed(const char *from_name, const char *to_name);
- void rep_hist_dump_stats(time_t now, int severity);
- void rep_hist_note_bytes_read(int num_bytes, time_t when);
- void rep_hist_note_bytes_written(int num_bytes, time_t when);
- int rep_hist_bandwidth_assess(void);
- char *rep_hist_get_bandwidth_lines(int for_extrainfo);
- void rep_hist_update_state(or_state_t *state);
- int rep_hist_load_state(or_state_t *state, char **err);
- void rep_history_clean(time_t before);
- void rep_hist_note_used_port(uint16_t port, time_t now);
- smartlist_t *rep_hist_get_predicted_ports(time_t now);
- void rep_hist_note_used_resolve(time_t now);
- void rep_hist_note_used_internal(time_t now, int need_uptime,
- int need_capacity);
- int rep_hist_get_predicted_internal(time_t now, int *need_uptime,
- int *need_capacity);
- int any_predicted_circuits(time_t now);
- int rep_hist_circbuilding_dormant(time_t now);
- typedef enum {
- SIGN_DIR, SIGN_RTR,
- VERIFY_DIR, VERIFY_RTR,
- ENC_ONIONSKIN, DEC_ONIONSKIN,
- TLS_HANDSHAKE_C, TLS_HANDSHAKE_S,
- REND_CLIENT, REND_MID, REND_SERVER,
- } pk_op_t;
- void note_crypto_pk_op(pk_op_t operation);
- void dump_pk_ops(int severity);
- void rep_hist_free_all(void);
- void hs_usage_note_publish_total(const char *service_id, time_t now);
- void hs_usage_note_publish_novel(const char *service_id, time_t now);
- void hs_usage_note_fetch_total(const char *service_id, time_t now);
- void hs_usage_note_fetch_successful(const char *service_id, time_t now);
- void hs_usage_write_statistics_to_file(time_t now);
- void hs_usage_free_all(void);
- void rend_client_introcirc_has_opened(origin_circuit_t *circ);
- void rend_client_rendcirc_has_opened(origin_circuit_t *circ);
- int rend_client_introduction_acked(origin_circuit_t *circ, const char *request,
- size_t request_len);
- void rend_client_refetch_renddesc(const char *query);
- int rend_client_remove_intro_point(extend_info_t *failed_intro,
- const char *query);
- int rend_client_rendezvous_acked(origin_circuit_t *circ, const char *request,
- size_t request_len);
- int rend_client_receive_rendezvous(origin_circuit_t *circ, const char *request,
- size_t request_len);
- void rend_client_desc_here(const char *query);
- extend_info_t *rend_client_get_random_intro(const char *query);
- int rend_client_send_introduction(origin_circuit_t *introcirc,
- origin_circuit_t *rendcirc);
- typedef struct rend_service_descriptor_t {
- crypto_pk_env_t *pk;
- int version;
- time_t timestamp;
- uint16_t protocols;
- int n_intro_points;
-
- char **intro_points;
-
- extend_info_t **intro_point_extend_info;
- } rend_service_descriptor_t;
- int rend_cmp_service_ids(const char *one, const char *two);
- void rend_process_relay_cell(circuit_t *circ, int command, size_t length,
- const char *payload);
- void rend_service_descriptor_free(rend_service_descriptor_t *desc);
- int rend_encode_service_descriptor(rend_service_descriptor_t *desc,
- int version,
- crypto_pk_env_t *key,
- char **str_out,
- size_t *len_out);
- rend_service_descriptor_t *rend_parse_service_descriptor(const char *str,
- size_t len);
- int rend_get_service_id(crypto_pk_env_t *pk, char *out);
- typedef struct rend_cache_entry_t {
- size_t len;
- time_t received;
- char *desc;
- rend_service_descriptor_t *parsed;
- } rend_cache_entry_t;
- void rend_cache_init(void);
- void rend_cache_clean(void);
- void rend_cache_free_all(void);
- int rend_valid_service_id(const char *query);
- int rend_cache_lookup_desc(const char *query, int version, const char **desc,
- size_t *desc_len);
- int rend_cache_lookup_entry(const char *query, int version,
- rend_cache_entry_t **entry_out);
- int rend_cache_store(const char *desc, size_t desc_len, int published);
- int rend_cache_size(void);
- int num_rend_services(void);
- int rend_config_services(or_options_t *options, int validate_only);
- int rend_service_load_keys(void);
- void rend_services_init(void);
- void rend_services_introduce(void);
- void rend_consider_services_upload(time_t now);
- void rend_service_intro_has_opened(origin_circuit_t *circuit);
- int rend_service_intro_established(origin_circuit_t *circuit,
- const char *request,
- size_t request_len);
- void rend_service_rendezvous_has_opened(origin_circuit_t *circuit);
- int rend_service_introduce(origin_circuit_t *circuit, const char *request,
- size_t request_len);
- void rend_service_relaunch_rendezvous(origin_circuit_t *oldcirc);
- int rend_service_set_connection_addr_port(edge_connection_t *conn,
- origin_circuit_t *circ);
- void rend_service_dump_stats(int severity);
- void rend_service_free_all(void);
- int rend_mid_establish_intro(or_circuit_t *circ, const char *request,
- size_t request_len);
- int rend_mid_introduce(or_circuit_t *circ, const char *request,
- size_t request_len);
- int rend_mid_establish_rendezvous(or_circuit_t *circ, const char *request,
- size_t request_len);
- int rend_mid_rendezvous(or_circuit_t *circ, const char *request,
- size_t request_len);
- crypto_pk_env_t *get_onion_key(void);
- time_t get_onion_key_set_at(void);
- void set_identity_key(crypto_pk_env_t *k);
- crypto_pk_env_t *get_identity_key(void);
- int identity_key_is_set(void);
- authority_cert_t *get_my_v3_authority_cert(void);
- crypto_pk_env_t *get_my_v3_authority_signing_key(void);
- void dup_onion_keys(crypto_pk_env_t **key, crypto_pk_env_t **last);
- void rotate_onion_key(void);
- crypto_pk_env_t *init_key_from_file(const char *fname, int generate,
- int severity);
- int init_keys(void);
- int check_whether_orport_reachable(void);
- int check_whether_dirport_reachable(void);
- void consider_testing_reachability(int test_or, int test_dir);
- void router_orport_found_reachable(void);
- void router_dirport_found_reachable(void);
- void router_perform_bandwidth_test(int num_circs, time_t now);
- int authdir_mode(or_options_t *options);
- int authdir_mode_v1(or_options_t *options);
- int authdir_mode_v2(or_options_t *options);
- int authdir_mode_v3(or_options_t *options);
- int authdir_mode_handles_descs(or_options_t *options);
- int authdir_mode_publishes_statuses(or_options_t *options);
- int authdir_mode_tests_reachability(or_options_t *options);
- int authdir_mode_bridge(or_options_t *options);
- int clique_mode(or_options_t *options);
- int server_mode(or_options_t *options);
- int advertised_server_mode(void);
- int proxy_mode(or_options_t *options);
- void consider_publishable_server(int force);
- int router_is_clique_mode(routerinfo_t *router);
- void router_upload_dir_desc_to_dirservers(int force);
- void mark_my_descriptor_dirty_if_older_than(time_t when);
- void mark_my_descriptor_dirty(void);
- void check_descriptor_bandwidth_changed(time_t now);
- void check_descriptor_ipaddress_changed(time_t now);
- void router_new_address_suggestion(const char *suggestion);
- int router_compare_to_my_exit_policy(edge_connection_t *conn);
- routerinfo_t *router_get_my_routerinfo(void);
- extrainfo_t *router_get_my_extrainfo(void);
- const char *router_get_my_descriptor(void);
- int router_digest_is_me(const char *digest);
- int router_is_me(routerinfo_t *router);
- int router_fingerprint_is_me(const char *fp);
- int router_pick_published_address(or_options_t *options, uint32_t *addr);
- int router_rebuild_descriptor(int force);
- int router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
- crypto_pk_env_t *ident_key);
- int extrainfo_dump_to_string(char *s, size_t maxlen, extrainfo_t *extrainfo,
- crypto_pk_env_t *ident_key);
- int is_legal_nickname(const char *s);
- int is_legal_nickname_or_hexdigest(const char *s);
- int is_legal_hexdigest(const char *s);
- void router_get_verbose_nickname(char *buf, routerinfo_t *router);
- void router_reset_warnings(void);
- void router_reset_reachability(void);
- void router_free_all(void);
- #ifdef ROUTER_PRIVATE
- void get_platform_str(char *platform, size_t len);
- #endif
- typedef struct trusted_dir_server_t {
- char *description;
- char *nickname;
- char *address;
- uint32_t addr;
- uint16_t dir_port;
- uint16_t or_port;
- char digest[DIGEST_LEN];
- char v3_identity_digest[DIGEST_LEN];
- unsigned int is_running:1;
-
- unsigned int has_accepted_serverdesc:1;
-
- authority_type_t type;
- smartlist_t *v3_certs;
- int n_networkstatus_failures;
- local_routerstatus_t fake_status;
- } trusted_dir_server_t;
- int router_reload_router_list(void);
- int get_n_authorities(authority_type_t type);
- int router_reload_networkstatus(void);
- smartlist_t *router_get_trusted_dir_servers(void);
- routerstatus_t *router_pick_directory_server(int requireother,
- int fascistfirewall,
- authority_type_t type,
- int retry_if_no_servers);
- routerstatus_t *router_pick_trusteddirserver(authority_type_t type,
- int requireother,
- int fascistfirewall,
- int retry_if_no_servers);
- trusted_dir_server_t *router_get_trusteddirserver_by_digest(
- const char *digest);
- trusted_dir_server_t *trusteddirserver_get_by_v3_auth_digest(
- const char *digest);
- authority_cert_t *authority_cert_get_by_digests(const char *id_digest,
- const char *sk_digest);
- void routerlist_add_family(smartlist_t *sl, routerinfo_t *router);
- void add_nickname_list_to_smartlist(smartlist_t *sl, const char *list,
- int must_be_running);
- int router_nickname_is_in_list(routerinfo_t *router, const char *list);
- routerinfo_t *routerlist_find_my_routerinfo(void);
- routerinfo_t *router_find_exact_exit_enclave(const char *address,
- uint16_t port);
- #define ROUTER_REQUIRED_MIN_BANDWIDTH 10000
- #define ROUTER_MAX_DECLARED_BANDWIDTH INT32_MAX
- int router_is_unreliable(routerinfo_t *router, int need_uptime,
- int need_capacity, int need_guard);
- uint32_t router_get_advertised_bandwidth(routerinfo_t *router);
- routerinfo_t *routerlist_sl_choose_by_bandwidth(smartlist_t *sl, int for_exit);
- routerstatus_t *routerstatus_sl_choose_by_bandwidth(smartlist_t *sl);
- routerinfo_t *router_choose_random_node(const char *preferred,
- const char *excluded,
- smartlist_t *excludedsmartlist,
- int need_uptime, int need_bandwidth,
- int need_guard,
- int allow_invalid, int strict,
- int weight_for_exit);
- routerinfo_t *router_get_by_nickname(const char *nickname,
- int warn_if_unnamed);
- int hexdigest_to_digest(const char *hexdigest, char *digest);
- routerinfo_t *router_get_by_hexdigest(const char *hexdigest);
- routerinfo_t *router_get_by_digest(const char *digest);
- signed_descriptor_t *router_get_by_descriptor_digest(const char *digest);
- signed_descriptor_t *router_get_by_extrainfo_digest(const char *digest);
- signed_descriptor_t *extrainfo_get_by_descriptor_digest(const char *digest);
- const char *signed_descriptor_get_body(signed_descriptor_t *desc);
- int router_digest_version_as_new_as(const char *digest, const char *cutoff);
- int router_digest_is_trusted_dir(const char *digest);
- routerlist_t *router_get_routerlist(void);
- void routerlist_reset_warnings(void);
- void routerlist_free(routerlist_t *routerlist);
- void dump_routerlist_mem_usage(int severity);
- void routerlist_remove(routerlist_t *rl, routerinfo_t *ri, int make_old);
- void routerinfo_free(routerinfo_t *router);
- void extrainfo_free(extrainfo_t *extrainfo);
- void routerstatus_free(routerstatus_t *routerstatus);
- void networkstatus_free(networkstatus_t *networkstatus);
- void routerlist_free_all(void);
- void router_set_status(const char *digest, int up);
- void routerlist_remove_old_routers(void);
- void networkstatus_list_clean(time_t now);
- int router_add_to_routerlist(routerinfo_t *router, const char **msg,
- int from_cache, int from_fetch);
- void router_add_extrainfo_to_routerlist(extrainfo_t *ei, const char **msg,
- int from_cache, int from_fetch);
- int router_load_single_router(const char *s, uint8_t purpose,
- const char **msg);
- void router_load_routers_from_string(const char *s, const char *eos,
- saved_location_t saved_location,
- smartlist_t *requested_fingerprints,
- uint8_t purpose);
- void router_load_extrainfo_from_string(const char *s, const char *eos,
- saved_location_t saved_location,
- smartlist_t *requested_fps);
- typedef enum {
- NS_FROM_CACHE, NS_FROM_DIR_BY_FP, NS_FROM_DIR_ALL, NS_GENERATED
- } networkstatus_source_t;
- int router_set_networkstatus(const char *s, time_t arrived_at,
- networkstatus_source_t source,
- smartlist_t *requested_fingerprints);
- char *networkstatus_get_cache_filename(const char *identity_digest);
- int router_exit_policy_all_routers_reject(uint32_t addr, uint16_t port,
- int need_uptime);
- int router_exit_policy_rejects_all(routerinfo_t *router);
- void add_trusted_dir_server(const char *nickname, const char *address,
- uint16_t dir_port, uint16_t or_port,
- const char *digest, authority_type_t type);
- void clear_trusted_dir_servers(void);
- int any_trusted_dir_is_v1_authority(void);
- networkstatus_t *networkstatus_get_by_digest(const char *digest);
- local_routerstatus_t *router_get_combined_status_by_digest(const char *digest);
- local_routerstatus_t *router_get_combined_status_by_descriptor_digest(
- const char *digest);
- networkstatus_vote_t *networkstatus_get_latest_consensus(void);
- networkstatus_vote_t *networkstatus_get_live_consensus(time_t now);
- int should_delay_dir_fetches(or_options_t *options);
- void update_networkstatus_downloads(time_t now);
- void routerlist_retry_directory_downloads(time_t now);
- void update_router_descriptor_downloads(time_t now);
- void update_extrainfo_downloads(time_t now);
- void routers_update_all_from_networkstatus(time_t now);
- void routers_update_status_from_networkstatus(smartlist_t *routers,
- int reset_failures);
- smartlist_t *router_list_superseded(void);
- int router_have_minimum_dir_info(void);
- void networkstatus_list_update_recent(time_t now);
- void router_reset_descriptor_download_failures(void);
- void router_reset_status_download_failures(void);
- int router_differences_are_cosmetic(routerinfo_t *r1, routerinfo_t *r2);
- int routerinfo_incompatible_with_extrainfo(routerinfo_t *ri, extrainfo_t *ei,
- const char **msg);
- const char *esc_router_info(routerinfo_t *router);
- char *networkstatus_getinfo_helper_single(routerstatus_t *rs);
- int getinfo_helper_networkstatus(control_connection_t *conn,
- const char *question, char **answer);
- void routerlist_assert_ok(routerlist_t *rl);
- void routerlist_check_bug_417(void);
- int trusted_dirs_reload_certs(void);
- int trusted_dirs_load_certs_from_string(const char *contents, int from_store);
- void trusted_dirs_flush_certs_to_disk(void);
- #define MAX_STATUS_TAG_LEN 32
- typedef struct tor_version_t {
- int major;
- int minor;
- int micro;
-
- enum { VER_PRE=0, VER_RC=1, VER_RELEASE=2, } status;
- int patchlevel;
- char status_tag[MAX_STATUS_TAG_LEN];
- int svn_revision;
- } tor_version_t;
- typedef enum version_status_t {
- VS_RECOMMENDED=0,
- VS_OLD=1,
- VS_NEW=2,
- VS_NEW_IN_SERIES=3,
- VS_UNRECOMMENDED=4
- } version_status_t;
- typedef struct combined_version_status_t {
-
- int n_versioning;
-
- version_status_t consensus;
-
- int n_concurring;
- } combined_version_status_t;
- char *compute_recommended_versions(time_t now, int client,
- const char *my_version,
- combined_version_status_t *status_out);
- int router_get_router_hash(const char *s, char *digest);
- int router_get_dir_hash(const char *s, char *digest);
- int router_get_runningrouters_hash(const char *s, char *digest);
- int router_get_networkstatus_v2_hash(const char *s, char *digest);
- int router_get_networkstatus_v3_hash(const char *s, char *digest);
- int router_get_extrainfo_hash(const char *s, char *digest);
- int router_append_dirobj_signature(char *buf, size_t buf_len,
- const char *digest,
- crypto_pk_env_t *private_key);
- int router_parse_list_from_string(const char **s, const char *eos,
- smartlist_t *dest,
- saved_location_t saved_location,
- int is_extrainfo);
- int router_parse_routerlist_from_directory(const char *s,
- routerlist_t **dest,
- crypto_pk_env_t *pkey,
- int check_version,
- int write_to_cache);
- int router_parse_runningrouters(const char *str);
- int router_parse_directory(const char *str);
- routerinfo_t *router_parse_entry_from_string(const char *s, const char *end,
- int cache_copy);
- extrainfo_t *extrainfo_parse_entry_from_string(const char *s, const char *end,
- int cache_copy, digestmap_t *routermap);
- addr_policy_t *router_parse_addr_policy_from_string(const char *s,
- int assume_action);
- version_status_t tor_version_is_obsolete(const char *myversion,
- const char *versionlist);
- version_status_t version_status_join(version_status_t a, version_status_t b);
- int tor_version_parse(const char *s, tor_version_t *out);
- int tor_version_as_new_as(const char *platform, const char *cutoff);
- int tor_version_compare(tor_version_t *a, tor_version_t *b);
- void sort_version_list(smartlist_t *lst, int remove_duplicates);
- void assert_addr_policy_ok(addr_policy_t *t);
- void dump_distinct_digest_count(int severity);
- networkstatus_t *networkstatus_parse_from_string(const char *s);
- networkstatus_vote_t *networkstatus_parse_vote_from_string(const char *s,
- int is_vote);
- ns_detached_signatures_t *networkstatus_parse_detached_signatures(
- const char *s, const char *eos);
- authority_cert_t *authority_cert_parse_from_string(const char *s,
- const char **end_of_string);
- #endif
|