Commit 3b5191d3 authored by Roger Dingledine's avatar Roger Dingledine
Browse files

various bugfixes and updates

redo all the config files for the new format (we'll redo them again soon)

fix (another! yuck) segfault in log_fn when input is too large
tor_tls_context_new() returns -1 for error, not NULL
fix segfault in check_conn_marked() on conn's that die during tls handshake

make ORs also initialize conn from router when we're the receiving node

make non-dirserver ORs upload descriptor to every dirserver on startup
add our local address to the descriptor
add Content-Length field to POST command
revert the Content-Length search in fetch_from_buf_http() to previous code
fix segfault in memmove in fetch_from_buf_http()
raise maximum allowed headers/body size in directory.c


svn:r484
parent 3d4ccb78
...@@ -54,17 +54,19 @@ static INLINE void format_msg(char *buf, size_t buf_len, ...@@ -54,17 +54,19 @@ static INLINE void format_msg(char *buf, size_t buf_len,
".%.3ld [%s] ", ".%.3ld [%s] ",
(long)now.tv_usec / 1000, sev_to_string(severity)); (long)now.tv_usec / 1000, sev_to_string(severity));
if(n > buf_len) if(n > buf_len)
n = buf_len; /* the *nprintf funcs return how many bytes they n = buf_len-1; /* the *nprintf funcs return how many bytes they
* _would_ print, if the output is truncated */ * _would_ print, if the output is truncated.
* Subtract one because the count doesn't include the \0 */
if (funcname) { if (funcname) {
n += snprintf(buf+n, buf_len-n, "%s(): ", funcname); n += snprintf(buf+n, buf_len-n, "%s(): ", funcname);
if(n > buf_len) if(n > buf_len)
n = buf_len; n = buf_len-1;
} }
n += vsnprintf(buf+n,buf_len-n,format,ap); n += vsnprintf(buf+n,buf_len-n,format,ap);
if(n > buf_len) if(n > buf_len)
n = buf_len; n = buf_len-1;
buf[n]='\n'; buf[n]='\n';
buf[n+1]='\0'; buf[n+1]='\0';
} }
......
...@@ -215,7 +215,7 @@ tor_tls_context_new(crypto_pk_env_t *rsa, ...@@ -215,7 +215,7 @@ tor_tls_context_new(crypto_pk_env_t *rsa,
cert = tor_tls_create_certificate(rsa, nickname); cert = tor_tls_create_certificate(rsa, nickname);
if (!cert) { if (!cert) {
log(LOG_ERR, "Error creating certificate"); log(LOG_ERR, "Error creating certificate");
return NULL; return -1;
} }
} }
......
# List of directory servers. # This is no longer a manually-editable file. It's just a
# Line format : address ORPort OPPort APPort DirPort bandwidth(bytes/s) # concatenation of a bunch of signed router descriptors.
# followed by the routers public key.
# ORport is where the router listens for routers/clients (speaking cells)
# APPort is where the router listens for applications (speaking socks)
# DirPort is where the router listens for directory download requests
# Router 1 router moria.mit.edu 9001 9021 9031 800000
router moria.mit.edu 9001 9021 9031 1000000 onion-key
-----BEGIN RSA PUBLIC KEY----- -----BEGIN RSA PUBLIC KEY-----
MIGJAoGBAMBBuk1sYxEg5jLAJy86U3GGJ7EGMSV7yoA6mmcsEVU3pwTUrpbpCmwS MIGJAoGBANoIvHieyHUTzIacbnWOnyTyzGrLOdXqbcjz2GGMxyHEd5K1bO1ZBNHP
7BvovoY3z4zk63NZVBErgKQUDkn3pp8n83xZgEf4GI27gdWIIwaBjEimuJlEY+7K 9i5qLQpN5viFk2K2rEGuG8tFgDEzSWZEtBqv3NVfUdiumdERWMBwlaQ0MVK4C+jf
nZ7kVMRoiXCbjL6VAtNa4Zy1Af/GOm0iCIDpholeujQ95xew7rQnAgMA//8= y5gZ8KI3o9ZictgPS1AQF+Kk932/vIHTuRIUKb4ILTnQilNvID0NAgMBAAE=
-----END RSA PUBLIC KEY-----
link-key
-----BEGIN RSA PUBLIC KEY-----
MIGJAoGBAPt97bGDd9siVjPd7Xuq2s+amMEOLIj9961aSdP6/OT+BS1Q4TX2dNOX
ZNAl63Z2fQISsR81+nfoqRLYCKxhajsD7LRvRTaRwUrWemVqFevmZ4nJrHw6FoU3
xNUIHRMA8X2DZ+l5qgnWZb7JU50ohhX5OpMSyysXnik51J8hD5mBAgMBAAE=
-----END RSA PUBLIC KEY----- -----END RSA PUBLIC KEY-----
signing-key signing-key
-----BEGIN RSA PUBLIC KEY----- -----BEGIN RSA PUBLIC KEY-----
MIGJAoGBAMBBuk1sYxEg5jLAJy86U3GGJ7EGMSV7yoA6mmcsEVU3pwTUrpbpCmwS MIGJAoGBAMHa0ZC/jo2Q2DrwKYF/6ZbmZ27PFYG91u4gUzzmZ/VXLpZ8wNzEV3oW
7BvovoY3z4zk63NZVBErgKQUDkn3pp8n83xZgEf4GI27gdWIIwaBjEimuJlEY+7K nt+I61048fBiC1frT1/DZ351n2bLSk9zJbB6jyGZJn0380FPRX3+cXyXS0Gq8Ril
nZ7kVMRoiXCbjL6VAtNa4Zy1Af/GOm0iCIDpholeujQ95xew7rQnAgMA//8= xkhMQf5XuNFUb8UmYPSOH4WErjvYjKvU+gfjbK/82Jo9SuHpYz+BAgMBAAE=
-----END RSA PUBLIC KEY----- -----END RSA PUBLIC KEY-----
router-signature
-----BEGIN SIGNATURE-----
fYcz+14lf2kilu0zGrkyAvfjNk2GfL5QClhdCiBuqy5fIkUS/969WZSWg9BXi7pK
5+EgR9hvY4nAtJ2SBoE+lyOx7miuT/uGfH68wNkC0Le2gULcprDYFKAEc5i1o/aS
Y/kuZIFDm2FXQPrYM88CIHAq8/3amUCskf2vC7l2eNE=
-----END SIGNATURE-----
router moria.mit.edu 9002 9022 9032 800000
# Router 2 onion-key
router moria.mit.edu 9002 9022 9032 1000000 -----BEGIN RSA PUBLIC KEY-----
MIGJAoGBAM4Cc/npgYC54XrYLC+grVxJp7PDmNO2DRRJOxKttBBtvLpnR1UaueTi
kyknT5kmlx+ihgZF/jmye//2dDUp2+kK/kSkpRV4xnDLXZmed+sNSQxqmm9TtZQ9
/hjpxhp5J9HmUTYhntBs+4E4CUKokmrI6oRLoln4SA39AX9QLPcnAgMBAAE=
-----END RSA PUBLIC KEY-----
link-key
-----BEGIN RSA PUBLIC KEY----- -----BEGIN RSA PUBLIC KEY-----
MIGJAoGBANX/HHRuudz274MFSQ4manX8DhtsIuogNUyco9/0dr+XsfioTGd3RgMj MIGJAoGBAN7JVeCIJ7+0ZJew5ScOU58rTUqjGt1Z1Rkursc7WabEb8jno45VZwIs
aSWlD87arkZO4hHBPHe0q89Z3s1UtUsyQ/VmsxSv9g2OCnF/dU2Nz4h6+Al3iNJF dkjnl31i36KHyyS7kQdHgkvG5EiyZiRipFAcoTaYv3Gvf1No9cXL6IhT3y/37dJ/
1UlWR4eiqBx3djxdIl/t+Nidw++YGc8QqRqkg0EhQCJ2fnOtHn9bAgMA//8= kFPEMb/G2wdkJCC+D8fMwHBwMuqAg0JGuhoBOz0ArCgK3fq0BLilAgMBAAE=
-----END RSA PUBLIC KEY----- -----END RSA PUBLIC KEY-----
signing-key signing-key
-----BEGIN RSA PUBLIC KEY----- -----BEGIN RSA PUBLIC KEY-----
MIGJAoGBANX/HHRuudz274MFSQ4manX8DhtsIuogNUyco9/0dr+XsfioTGd3RgMj MIGJAoGBAOcrht/y5rkaahfX7sMe2qnpqoPibsjTSJaDvsUtaNP/Bq0MgNDGOR48
aSWlD87arkZO4hHBPHe0q89Z3s1UtUsyQ/VmsxSv9g2OCnF/dU2Nz4h6+Al3iNJF rtwfqTRff275Edkp/UYw3G3vSgKCJr76/bqOHCmkiZrnPV1zxNfrK18gNw2Cxre0
1UlWR4eiqBx3djxdIl/t+Nidw++YGc8QqRqkg0EhQCJ2fnOtHn9bAgMA//8= nTA+fD8JQqpPtb8b0SnG9kwy75eS//sRu7TErie2PzGMxrf9LH0LAgMBAAE=
-----END RSA PUBLIC KEY----- -----END RSA PUBLIC KEY-----
router-signature
-----BEGIN SIGNATURE-----
Hyx1fJFJaR9j7OpEg4qdxKo+AMXIZl6250AuiYmvdcwWD2VBJyhSbptB/vMLQGrU
/PGWLlZus90xD/mKesc4b0CkwKD6eWI90Wn34JwBUGHalN/qm42tMMoq3slOWae0
Da9JmxiYqApXwwaHWR9WwNHmkXkWfvTmZDSFkdEMgV0=
-----END SIGNATURE-----
# Router 3 router moria.mit.edu 9003 9023 9033 800000
router moria.mit.edu 9003 9023 9033 1000000 onion-key
-----BEGIN RSA PUBLIC KEY-----
MIGJAoGBANS6J/Er9fYo03fjUUVesc7We9Z6xIevyDJH39pYS4NUlcr5ExYgSVFJ
95aLCNx1x8Rf5YtiBKYuT3plBO/+rfuX+0iAGNkz/y3SlJVGz6aeptU3wN8CkvCL
zATEcnl4QSPhHX0wFB9A3t7wZ+Bat1PTI029lax/BkoS9JG5onHPAgMBAAE=
-----END RSA PUBLIC KEY-----
link-key
-----BEGIN RSA PUBLIC KEY----- -----BEGIN RSA PUBLIC KEY-----
MIGJAoGBAJfkNWCaNkYIRwfHT06KBU6dz8W1xDpW5ezGJwAOoxCX3/ZNoUicb/1V MIGJAoGBAKUMY8p+7LBu7dEJnOR9HqbfcD6c4/f9GqJt3o29uu4XJPD8z2XGVBik
oB3OzW6VxWIiht3da/3K0ywiBOOCcf6BabKoMdiPpH7NIeu6XRmBYK2uqW13gBgh pZBLijhYS6U7GFg0NLR4zBlsLyB8TxHeaz5KJidJjy+BfC01jz1xwVTYDlmGVpc1
xJbQBb58Nx8Fr05XkvLG6i+vTDY3MZOW3E2/DwSe/jFzuHSD5b3nAgMA//8= 0mw0Ag0ND6aOQKKhelxhTI3Bf0R9olEXuSUKEWx3EMIz2qhLd9oDAgMBAAE=
-----END RSA PUBLIC KEY----- -----END RSA PUBLIC KEY-----
signing-key signing-key
-----BEGIN RSA PUBLIC KEY----- -----BEGIN RSA PUBLIC KEY-----
MIGJAoGBAJfkNWCaNkYIRwfHT06KBU6dz8W1xDpW5ezGJwAOoxCX3/ZNoUicb/1V MIGJAoGBAMqgq83cwzSid2LSvzsn2rvkD8U0tWvqF6PuQAsKP3QHFqtBO+66pnIm
oB3OzW6VxWIiht3da/3K0ywiBOOCcf6BabKoMdiPpH7NIeu6XRmBYK2uqW13gBgh CbiY2e6o01tmR47t557LuUCodEc8Blggxjg3ZEzvP42hsGB9LwQbcrU7grPRk0G0
xJbQBb58Nx8Fr05XkvLG6i+vTDY3MZOW3E2/DwSe/jFzuHSD5b3nAgMA//8= IltsOF9TZ+66gCeU7LxExLdAMqT2Tx6VT4IREPJMeNxSiceEjbABAgMBAAE=
-----END RSA PUBLIC KEY----- -----END RSA PUBLIC KEY-----
router-signature
-----BEGIN SIGNATURE-----
xm7Nmk7EmtDIrXZ/Hh2LBbG3oTuwCjY3XrVHpIbg6ttuoYJx3Ai1MdOHHBbUDVdz
bRE6WV5fXuVgmgcWLP6p364Vymw6i2ff/lkEMqHV4NOAWZ1RbFwZQ5OjEAjXIhH/
VlVX83wBSM0EefJwwXM7H075MU1MB+f2yRlTZ0/Xp0U=
-----END SIGNATURE-----
# Sample configuration file for httpap.
# local port on which the onion proxy is running
OnionProxy 9021
# maximum number of incoming connections
MaxConn 500
# run in anonymizing mode (0=no/1=yes)
Anonimize 0
# timeout for incoming connections (seconds)
ConnTimeout 6000
...@@ -5,10 +5,7 @@ OnionRouter 1 ...@@ -5,10 +5,7 @@ OnionRouter 1
# List of routers # List of routers
RouterFile ../config/routers.or RouterFile ../config/routers.or
# Private key DataDirectory moria1
PrivateKeyFile moria1-private
SigningPrivateKeyFile moria1-private
CertFile moria1-cert
Nickname moria1 Nickname moria1
CoinWeight 0.01 CoinWeight 0.01
......
-----BEGIN RSA PRIVATE KEY-----
MIICXQIBAAKBgQDAQbpNbGMRIOYywCcvOlNxhiexBjEle8qAOppnLBFVN6cE1K6W
6QpsEuwb6L6GN8+M5OtzWVQRK4CkFA5J96afJ/N8WYBH+BiNu4HViCMGgYxIpriZ
RGPuyp2e5FTEaIlwm4y+lQLTWuGctQH/xjptIgiA6YaJXro0PecXsO60JwIDAP//
AoGBAKr0nL8o2Ze6mqtHK57YOb6xisihTCCinYh2pHXV0xdbXaxXUb2d4VROf6So
ruJDTp6UxDkLbR3ZjnJ0D9CxOCY+HHC17k+svimV6+bu22uvVJuwPM2kvZxYdM5n
mNvGBikwB6Uk8ZtQ+SDwa/sRr/Q49a2hJF6VjYn/HnqXKWJ/AkEA6uYt3AYaNcZ+
cI+evYSOJ9TaVZ5h+i9IWlYl+Oo72dXr1DvcNYxibh1yHgCf72QctM57Qxd6U+N4
7hQmARP3IQJBANGG7f6v5eDVG/Rd4gupBMCdcuwefRY1tMqUmwYP9Ps3ZsHSmNhk
aRKpVXXTFiJSwgI5LzgsjzMeaBVHvWFh6kcCQGMCjeDl91wX2Qz8pe4ZWCBECJbV
C7MGNu5Cc93BYCFuGwecjqqkqXWBIMWkGw166NBiRDiIktkEntJAElDQoh8CQQC4
vUXXUYFpio6eNNyf0HcnInkTs71RME9E4+bKcSAaFmTJzK3bh/NEDVyMrNcyvlYY
N+9f4HlqNXtOLnyhtuw7AkAYHlK/fgem67SYl9Uu+1XnVX3Ktn/RbW1jeLRF8E8+
urDuSzz4nbbRxDRmsZqMzsZlo0aH0DMsn+mbyTkDSQWA
-----END RSA PRIVATE KEY-----
-----BEGIN RSA PUBLIC KEY-----
MIGJAoGBAMBBuk1sYxEg5jLAJy86U3GGJ7EGMSV7yoA6mmcsEVU3pwTUrpbpCmwS
7BvovoY3z4zk63NZVBErgKQUDkn3pp8n83xZgEf4GI27gdWIIwaBjEimuJlEY+7K
nZ7kVMRoiXCbjL6VAtNa4Zy1Af/GOm0iCIDpholeujQ95xew7rQnAgMA//8=
-----END RSA PUBLIC KEY-----
...@@ -5,10 +5,7 @@ OnionRouter 1 ...@@ -5,10 +5,7 @@ OnionRouter 1
# List of routers # List of routers
RouterFile ../config/routers.or RouterFile ../config/routers.or
# Private key DataDirectory moria2
PrivateKeyFile moria2-private
SigningPrivateKeyFile moria2-private
CertFile moria2-cert
Nickname moria2 Nickname moria2
CoinWeight 0.01 CoinWeight 0.01
......
-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQDV/xx0brnc9u+DBUkOJmp1/A4bbCLqIDVMnKPf9Ha/l7H4qExn
d0YDI2klpQ/O2q5GTuIRwTx3tKvPWd7NVLVLMkP1ZrMUr/YNjgpxf3VNjc+IevgJ
d4jSRdVJVkeHoqgcd3Y8XSJf7fjYncPvmBnPEKkapINBIUAidn5zrR5/WwIDAP//
AoGAfSHuFF8HGySbR3bxo7DINw9+izVxS9nrJFxICu8sEsnVQZwicS5mZaItUMlq
HL1pXtPk8oixVSxBFrrCi1DQZdvMWpcmtlhfdFfp+DZlJ9nTDpECjhzRcFv6l9FA
xyRN7GHtherauc7ToNpkY08YOVl215lsS31moUJbNnLpkecCQQDxOh6/oc1WBTlM
XXKo9yUYcMQauUUHVdeiAxUShwnJ2NXRJpCZHBX9C0jOCxDUIHC73DlazYQocnJN
9NQn+euvAkEA4xoUd8GKQFBfX34wxWXkSX+hN58mz+8VGqaTUo5UQgHu2VeIq9sq
xr4M7i5mMVipr0bIg1m8MIfP3Ysqahz2FQJAXv8SOukilZKEMua/nelxNSEdWuNw
YmPgXl01GZDnG7PPZzxnDbJtGyMcvsB6UQNXaFIRqCO2vuRQh6OBb3+KnwJABOnz
X1K1Wn2Xrd6e2MQ/Jr5DsUHIzsSRD3auIrVrFCCy1bK0jbx5t2qQHi9rMXiGlGty
fhoNJnH2t1fcMMv1NwJBAM7e/cUAcKhaVWg+iuTL36xmHec99Tnw04yHOwGxw0l8
BwO/vtDIX+gx6MIKYe+i4uNSVIt6Ww049eki5a56Xp8=
-----END RSA PRIVATE KEY-----
-----BEGIN RSA PUBLIC KEY-----
MIGJAoGBANX/HHRuudz274MFSQ4manX8DhtsIuogNUyco9/0dr+XsfioTGd3RgMj
aSWlD87arkZO4hHBPHe0q89Z3s1UtUsyQ/VmsxSv9g2OCnF/dU2Nz4h6+Al3iNJF
1UlWR4eiqBx3djxdIl/t+Nidw++YGc8QqRqkg0EhQCJ2fnOtHn9bAgMA//8=
-----END RSA PUBLIC KEY-----
...@@ -5,10 +5,7 @@ OnionRouter 1 ...@@ -5,10 +5,7 @@ OnionRouter 1
# List of routers # List of routers
RouterFile ../config/routers.or RouterFile ../config/routers.or
# Private key DataDirectory moria3
PrivateKeyFile moria3-private
SigningPrivateKeyFile moria3-private
CertFile moria3-cert
Nickname moria3 Nickname moria3
CoinWeight 0.01 CoinWeight 0.01
......
-----BEGIN RSA PRIVATE KEY-----
MIICWwIBAAKBgQCX5DVgmjZGCEcHx09OigVOnc/FtcQ6VuXsxicADqMQl9/2TaFI
nG/9VaAdzs1ulcViIobd3Wv9ytMsIgTjgnH+gWmyqDHYj6R+zSHrul0ZgWCtrqlt
d4AYIcSW0AW+fDcfBa9OV5Lyxuovr0w2NzGTltxNvw8Env4xc7h0g+W95wIDAP//
AoGAcUkHEFlT/8NALQ9VN1qrm/PS37mWWVEUwJHxvD6m4JEF/AqV6muG+aoMGwdN
wl26GhD2QwLdA59+6pMx1Jgod+D9aM1F8zE3h0GnoncsJhtZn1aks0tmE7UNZLou
Nsb+hnZD/lDN8WbZoLoKHJV1TXIaQ79VlIzt46gILyN7Ol8CQQDFeZEOnXmddgnY
hXmfUujZbNs9Fa2M2GfnCxZuwn/lU7NebYcpkCoXp1ro+O1slOSYymdbAC8Di6H6
I8YsYiPPAkEAxOg5O3yPviEPHcav+UfEntd3U4Rebpry+KunuFriMf5wQNWSBmgY
d+jfOgaNOntfeNqywPDxU9/3+S9prneSaQJAdeBRTUme1HM8vcIR5gL0TlS/hkrJ
3b8+bHDTubrE8FkRhyvp/OIxckXwksbBBzQ7U8sM0qeDt6J9tvw3k8+8bQJAXSMM
JRUhulmxVhDOUMCo2qJYjRNLFa/T2D5ZROYRnyMuD3iT2CeYqmAJ5aX69sJNfKE9
6cxgkcKjNroJwJVDDwJAbXjnN3MUSKITvlcVpBTlGozwOVjiPJ+1sbgBy4HzcffG
UMHFK4hprBdtnV/kePtErGM3zlk+qh4VkUrp3MshEQ==
-----END RSA PRIVATE KEY-----
-----BEGIN RSA PUBLIC KEY-----
MIGJAoGBAJfkNWCaNkYIRwfHT06KBU6dz8W1xDpW5ezGJwAOoxCX3/ZNoUicb/1V
oB3OzW6VxWIiht3da/3K0ywiBOOCcf6BabKoMdiPpH7NIeu6XRmBYK2uqW13gBgh
xJbQBb58Nx8Fr05XkvLG6i+vTDY3MZOW3E2/DwSe/jFzuHSD5b3nAgMA//8=
-----END RSA PUBLIC KEY-----
# List of core onion routers in the network. router moria.mit.edu 9001 9021 9031 800000
# Line format : address ORPort OPPort APPort DirPort bandwidth(bytes/s) onion-key
# followed by the routers public key.
# ORport is where the router listens for routers/clients (speaking cells)
# APPort is where the router listens for applications (speaking socks)
# DirPort is where the router listens for directory download requests
# Router 1
router moria.mit.edu 9001 9021 9031 1000000
-----BEGIN RSA PUBLIC KEY----- -----BEGIN RSA PUBLIC KEY-----
MIGJAoGBAMBBuk1sYxEg5jLAJy86U3GGJ7EGMSV7yoA6mmcsEVU3pwTUrpbpCmwS MIGJAoGBANoIvHieyHUTzIacbnWOnyTyzGrLOdXqbcjz2GGMxyHEd5K1bO1ZBNHP
7BvovoY3z4zk63NZVBErgKQUDkn3pp8n83xZgEf4GI27gdWIIwaBjEimuJlEY+7K 9i5qLQpN5viFk2K2rEGuG8tFgDEzSWZEtBqv3NVfUdiumdERWMBwlaQ0MVK4C+jf
nZ7kVMRoiXCbjL6VAtNa4Zy1Af/GOm0iCIDpholeujQ95xew7rQnAgMA//8= y5gZ8KI3o9ZictgPS1AQF+Kk932/vIHTuRIUKb4ILTnQilNvID0NAgMBAAE=
-----END RSA PUBLIC KEY----- -----END RSA PUBLIC KEY-----
signing-key link-key
-----BEGIN RSA PUBLIC KEY-----
MIGJAoGBAMBBuk1sYxEg5jLAJy86U3GGJ7EGMSV7yoA6mmcsEVU3pwTUrpbpCmwS
7BvovoY3z4zk63NZVBErgKQUDkn3pp8n83xZgEf4GI27gdWIIwaBjEimuJlEY+7K
nZ7kVMRoiXCbjL6VAtNa4Zy1Af/GOm0iCIDpholeujQ95xew7rQnAgMA//8=
-----END RSA PUBLIC KEY-----
accept *:*
# Router 2
router moria.mit.edu 9002 9022 9032 1000000
-----BEGIN RSA PUBLIC KEY----- -----BEGIN RSA PUBLIC KEY-----
MIGJAoGBANX/HHRuudz274MFSQ4manX8DhtsIuogNUyco9/0dr+XsfioTGd3RgMj MIGJAoGBAPt97bGDd9siVjPd7Xuq2s+amMEOLIj9961aSdP6/OT+BS1Q4TX2dNOX
aSWlD87arkZO4hHBPHe0q89Z3s1UtUsyQ/VmsxSv9g2OCnF/dU2Nz4h6+Al3iNJF ZNAl63Z2fQISsR81+nfoqRLYCKxhajsD7LRvRTaRwUrWemVqFevmZ4nJrHw6FoU3
1UlWR4eiqBx3djxdIl/t+Nidw++YGc8QqRqkg0EhQCJ2fnOtHn9bAgMA//8= xNUIHRMA8X2DZ+l5qgnWZb7JU50ohhX5OpMSyysXnik51J8hD5mBAgMBAAE=
-----END RSA PUBLIC KEY----- -----END RSA PUBLIC KEY-----
signing-key signing-key
-----BEGIN RSA PUBLIC KEY----- -----BEGIN RSA PUBLIC KEY-----
MIGJAoGBANX/HHRuudz274MFSQ4manX8DhtsIuogNUyco9/0dr+XsfioTGd3RgMj MIGJAoGBAMHa0ZC/jo2Q2DrwKYF/6ZbmZ27PFYG91u4gUzzmZ/VXLpZ8wNzEV3oW
aSWlD87arkZO4hHBPHe0q89Z3s1UtUsyQ/VmsxSv9g2OCnF/dU2Nz4h6+Al3iNJF nt+I61048fBiC1frT1/DZ351n2bLSk9zJbB6jyGZJn0380FPRX3+cXyXS0Gq8Ril
1UlWR4eiqBx3djxdIl/t+Nidw++YGc8QqRqkg0EhQCJ2fnOtHn9bAgMA//8= xkhMQf5XuNFUb8UmYPSOH4WErjvYjKvU+gfjbK/82Jo9SuHpYz+BAgMBAAE=
-----END RSA PUBLIC KEY----- -----END RSA PUBLIC KEY-----
router-signature
-----BEGIN SIGNATURE-----
fYcz+14lf2kilu0zGrkyAvfjNk2GfL5QClhdCiBuqy5fIkUS/969WZSWg9BXi7pK
5+EgR9hvY4nAtJ2SBoE+lyOx7miuT/uGfH68wNkC0Le2gULcprDYFKAEc5i1o/aS
Y/kuZIFDm2FXQPrYM88CIHAq8/3amUCskf2vC7l2eNE=
-----END SIGNATURE-----
# Router 3 router moria.mit.edu 9002 9022 9032 800000
router moria.mit.edu 9003 9023 9033 1000000 onion-key
-----BEGIN RSA PUBLIC KEY----- -----BEGIN RSA PUBLIC KEY-----
MIGJAoGBAJfkNWCaNkYIRwfHT06KBU6dz8W1xDpW5ezGJwAOoxCX3/ZNoUicb/1V MIGJAoGBAM4Cc/npgYC54XrYLC+grVxJp7PDmNO2DRRJOxKttBBtvLpnR1UaueTi
oB3OzW6VxWIiht3da/3K0ywiBOOCcf6BabKoMdiPpH7NIeu6XRmBYK2uqW13gBgh kyknT5kmlx+ihgZF/jmye//2dDUp2+kK/kSkpRV4xnDLXZmed+sNSQxqmm9TtZQ9
xJbQBb58Nx8Fr05XkvLG6i+vTDY3MZOW3E2/DwSe/jFzuHSD5b3nAgMA//8= /hjpxhp5J9HmUTYhntBs+4E4CUKokmrI6oRLoln4SA39AX9QLPcnAgMBAAE=
-----END RSA PUBLIC KEY-----
link-key
-----BEGIN RSA PUBLIC KEY-----
MIGJAoGBAN7JVeCIJ7+0ZJew5ScOU58rTUqjGt1Z1Rkursc7WabEb8jno45VZwIs
dkjnl31i36KHyyS7kQdHgkvG5EiyZiRipFAcoTaYv3Gvf1No9cXL6IhT3y/37dJ/
kFPEMb/G2wdkJCC+D8fMwHBwMuqAg0JGuhoBOz0ArCgK3fq0BLilAgMBAAE=
-----END RSA PUBLIC KEY----- -----END RSA PUBLIC KEY-----
signing-key signing-key
-----BEGIN RSA PUBLIC KEY----- -----BEGIN RSA PUBLIC KEY-----
MIGJAoGBAJfkNWCaNkYIRwfHT06KBU6dz8W1xDpW5ezGJwAOoxCX3/ZNoUicb/1V MIGJAoGBAOcrht/y5rkaahfX7sMe2qnpqoPibsjTSJaDvsUtaNP/Bq0MgNDGOR48
oB3OzW6VxWIiht3da/3K0ywiBOOCcf6BabKoMdiPpH7NIeu6XRmBYK2uqW13gBgh rtwfqTRff275Edkp/UYw3G3vSgKCJr76/bqOHCmkiZrnPV1zxNfrK18gNw2Cxre0
xJbQBb58Nx8Fr05XkvLG6i+vTDY3MZOW3E2/DwSe/jFzuHSD5b3nAgMA//8= nTA+fD8JQqpPtb8b0SnG9kwy75eS//sRu7TErie2PzGMxrf9LH0LAgMBAAE=
-----END RSA PUBLIC KEY----- -----END RSA PUBLIC KEY-----
router-signature
-----BEGIN SIGNATURE-----
Hyx1fJFJaR9j7OpEg4qdxKo+AMXIZl6250AuiYmvdcwWD2VBJyhSbptB/vMLQGrU
/PGWLlZus90xD/mKesc4b0CkwKD6eWI90Wn34JwBUGHalN/qm42tMMoq3slOWae0
Da9JmxiYqApXwwaHWR9WwNHmkXkWfvTmZDSFkdEMgV0=
-----END SIGNATURE-----
router moria.mit.edu 9004 9024 0 1000000 router moria.mit.edu 9003 9023 9033 800000
onion-key
-----BEGIN RSA PUBLIC KEY----- -----BEGIN RSA PUBLIC KEY-----
MIGJAoGBAKD2BDZQpGq/aAbZ7t+/7qktZVEbhUGe097gIjWH9gXcIOIm0CJMe3rN MIGJAoGBANS6J/Er9fYo03fjUUVesc7We9Z6xIevyDJH39pYS4NUlcr5ExYgSVFJ
MsBJsQMi5Uwqrz+Invb5n6bswrNlJp/bCKBhGTvUCfxg7c8xZy71PPSIPnTg1qXl 95aLCNx1x8Rf5YtiBKYuT3plBO/+rfuX+0iAGNkz/y3SlJVGz6aeptU3wN8CkvCL
p5fyAkgCYkZNgEEZzQDHv1GRvLCs92kURjSJE5y8QU0dXfbzms8PAgMA//8= zATEcnl4QSPhHX0wFB9A3t7wZ+Bat1PTI029lax/BkoS9JG5onHPAgMBAAE=
-----END RSA PUBLIC KEY----- -----END RSA PUBLIC KEY-----
link-key
router mosg.cl.cam.ac.uk 9005 9025 0 1000000
-----BEGIN RSA PUBLIC KEY----- -----BEGIN RSA PUBLIC KEY-----
MIGJAoGBAMMHEjhhawM6S14ETFVcvByU7D/baN2JMcCweKKJ7zcSurDnpgRH/Uo7 MIGJAoGBAKUMY8p+7LBu7dEJnOR9HqbfcD6c4/f9GqJt3o29uu4XJPD8z2XGVBik
05+bZE3BCy4OkAqQbGlKd/ejBOuXjEtS0mJo5xwDX9StKguhgFRk60hhrF2OFJm4 pZBLijhYS6U7GFg0NLR4zBlsLyB8TxHeaz5KJidJjy+BfC01jz1xwVTYDlmGVpc1
VLItXA6U2NLOrc+FBCv/9laLpBrxOb8Wuct0l/lyZ2/OfE9yYhC3AgMA//8= 0mw0Ag0ND6aOQKKhelxhTI3Bf0R9olEXuSUKEWx3EMIz2qhLd9oDAgMBAAE=
-----END RSA PUBLIC KEY----- -----END RSA PUBLIC KEY-----
signing-key
router 66.17.17.207 9006 9026 0 1000000
-----BEGIN RSA PUBLIC KEY----- -----BEGIN RSA PUBLIC KEY-----
MIGJAoGBAL5cpmH34kVfmHd+A00vMton3pLGHAVf7BYkSMif8e/O5zXTUXRi4w78 MIGJAoGBAMqgq83cwzSid2LSvzsn2rvkD8U0tWvqF6PuQAsKP3QHFqtBO+66pnIm
jDcGNo2yFM3htTpT5/tWs/Z2+B/mx8Kz+AhHzZ9z0PdQreDSqxXjF+jmfCyx9Teq CbiY2e6o01tmR47t557LuUCodEc8Blggxjg3ZEzvP42hsGB9LwQbcrU7grPRk0G0
jU9QA3GZiguLYV2pcs6Oll20svPSt0WRAR4YUmDeQmEYIZdBGnrVAgMBAAE= IltsOF9TZ+66gCeU7LxExLdAMqT2Tx6VT4IREPJMeNxSiceEjbABAgMBAAE=
-----END RSA PUBLIC KEY----- -----END RSA PUBLIC KEY-----
router-signature
-----BEGIN SIGNATURE-----
xm7Nmk7EmtDIrXZ/Hh2LBbG3oTuwCjY3XrVHpIbg6ttuoYJx3Ai1MdOHHBbUDVdz
bRE6WV5fXuVgmgcWLP6p364Vymw6i2ff/lkEMqHV4NOAWZ1RbFwZQ5OjEAjXIhH/
VlVX83wBSM0EefJwwXM7H075MU1MB+f2yRlTZ0/Xp0U=
-----END SIGNATURE-----
# Sample configuration file for smtpap.
# Local port on which the onion proxy is running.
OnionProxy 3000
# Maximum number of incoming connections.
MaxConn 100
# Run in anonymizing mode.
Anonimize 0
# Timeout for incoming connections.
ConnTimeout 6000
# Configuration file for or
# List of routers
RouterFile ../config/routers.or
# Private key
PrivateKeyFile ts4-private
CoinWeight 0.0001
ORPort 9004
OPPort 9014
APPort 9024
# Maximum number of connections.
MaxConn 900
-----BEGIN RSA PRIVATE KEY-----
MIICWwIBAAKBgQCg9gQ2UKRqv2gG2e7fv+6pLWVRG4VBntPe4CI1h/YF3CDiJtAi
THt6zTLASbEDIuVMKq8/iJ72+Z+m7MKzZSaf2wigYRk71An8YO3PMWcu9Tz0iD50
4Nal5aeX8gJIAmJGTYBBGc0Ax79RkbywrPdpFEY0iROcvEFNHV3285rPDwIDAP//
AoGATT1a0ssVMK55wYNlO5N9QXuiEcWef1OOTokr84vpgklbsOEA0PY0Vum+PDOY
vHIDKcfFT+oG8dpKjow7GgCrwK4sDb5m9unWyWVPBlTntCUsjg8IKOr0a5/g1s/M
vb8BVcTeTEbh/VpUzHNQVb3rq+iaWj2bi/8NVUNqfP05n78CQQDOXsIOjgaI3jdc
Agp/g7nKQpqQbmBEnyKCo7tQHMLpn8XCJuua6xfuXssqKGKEp+tKsYE421P7aSYh
TQu939m9AkEAx6uhWQvSm7rIvkgKMuMCDOM5tjdqfDZ3PuTv2i4VhZ3psJhg0oT9
r5KFw/Uwam126Mmh5h+M6LBgX7o6DVDquwJAfGUsX9BNkqd8h+sm3Rl0g3X+/pP2
jPN00bGg5p/swJz14cg1hhvBDYijALFOa4Je3umzbMfo/BDSc58Tdeu2+wJACgFv
szn+47Sby8S/55Svqvz93VNcNV2gD1LgJ7r+5xT0zsIxfD4ORF6H+n2/ztUTDnVJ
BiUS4KvXQCNBE/Pl9wJAMnYAfMOolyh96NWCH9ZN3OJmWojpgXjMlw5H02kkRKpZ
HWnksj3ErNlCo5juXaaOwESBZBB/5+ngsIMPwWT0lg==
-----END RSA PRIVATE KEY-----
...@@ -38,6 +38,10 @@ static int find_str_in_str(const char *str, int str_len, ...@@ -38,6 +38,10 @@ static int find_str_in_str(const char *str, int str_len,
return -1; return -1;
} }
int find_on_inbuf(char *string, int string_len, buf_t *buf) {
return find_str_in_str(string, string_len, buf->buf, buf->datalen);
}
/* Create and return a new buf of size 'size' /* Create and return a new buf of size 'size'
*/ */
buf_t *buf_new_with_capacity(size_t size) { buf_t *buf_new_with_capacity(size_t size) {
...@@ -206,7 +210,7 @@ int flush_buf_tls(tor_tls *tls, buf_t *buf, int *buf_flushlen) ...@@ -206,7 +210,7 @@ int flush_buf_tls(tor_tls *tls, buf_t *buf, int *buf_flushlen)
return r; return r;
} }
int write_to_buf(char *string, int string_len, buf_t *buf) { int write_to_buf(const char *string, int string_len, buf_t *buf) {
/* append string to buf (growing as needed, return -1 if "too big") /* append string to buf (growing as needed, return -1 if "too big")
* return total number of bytes on the buf * return total number of bytes on the buf
...@@ -285,11 +289,12 @@ int fetch_from_buf_http(buf_t *buf, ...@@ -285,11 +289,12 @@ int fetch_from_buf_http(buf_t *buf,
} }
#define CONTENT_LENGTH "\r\nContent-Length: " #define CONTENT_LENGTH "\r\nContent-Length: "
i = find_str_in_str(CONTENT_LENGTH, sizeof(CONTENT_LENGTH), i = find_str_in_str(CONTENT_LENGTH, strlen(CONTENT_LENGTH),
headers, headerlen); headers, headerlen);
if(i > 0) { if(i > 0) {
contentlen = atoi(headers+i); contentlen = atoi(headers+i);
/* XXX What if content-length is malformed? */ /* XXX What if content-length is malformed? */
log_fn(LOG_DEBUG,"Got a contentlen of %d.",contentlen);
if(bodylen < contentlen) { if(bodylen < contentlen) {
log_fn(LOG_DEBUG,"body not all here yet."); log_fn(LOG_DEBUG,"body not all here yet.");
return 0; /* not all there yet */ return 0; /* not all there yet */
...@@ -307,7 +312,7 @@ int fetch_from_buf_http(buf_t *buf, ...@@ -307,7 +312,7 @@ int fetch_from_buf_http(buf_t *buf,
body_out[bodylen] = 0; /* null terminate it */ body_out[bodylen] = 0; /* null terminate it */
} }
buf->datalen -= (headerlen+bodylen); buf->datalen -= (headerlen+bodylen);
memmove(buf, buf->buf+headerlen+bodylen, buf->datalen); memmove(buf->buf, buf->buf+headerlen+bodylen, buf->datalen);
return 1; return 1;
} }
...@@ -401,15 +406,6 @@ int fetch_from_buf_socks(buf_t *buf, ...@@ -401,15 +406,6 @@ int fetch_from_buf_socks(buf_t *buf,
return 1; return 1;
} }
int find_on_inbuf(char *string, int string_len, buf_t *buf) {
/* find first instance of needle 'string' on haystack 'buf'. return how
* many bytes from the beginning of buf to the end of string.
* If it's not there, return -1.
*/
return find_str_in_str(string, string_len, buf->buf, buf->datalen);
}
/* /*
Local Variables: Local Variables:
mode:c mode:c
......
...@@ -304,19 +304,14 @@ static int connection_tls_finish_handshake(connection_t *conn) { ...@@ -304,19 +304,14 @@ static int connection_tls_finish_handshake(connection_t *conn) {
return -1; return -1;
} }
log_fn(LOG_DEBUG,"The router's pk matches the one we meant to connect to. Good."); log_fn(LOG_DEBUG,"The router's pk matches the one we meant to connect to. Good.");
crypto_free_pk_env(pk);
} else { } else {
if(connection_exact_get_by_addr_port(router->addr,router->or_port)) { if(connection_exact_get_by_addr_port(router->addr,router->or_port)) {
log_fn(LOG_INFO,"That router is already connected. Dropping."); log_fn(LOG_INFO,"That router is already connected. Dropping.");
return -1; return -1;
} }
conn->link_pkey = pk; connection_or_init_conn_from_router(conn, router);
conn->bandwidth = router->bandwidth;
conn->addr = router->addr, conn->port = router->or_port;
if(conn->address)
free(conn->address);
conn->address = strdup(router->address);
} }
crypto_free_pk_env(pk);
} else { /* it's an OP */ } else { /* it's an OP */
conn->bandwidth = DEFAULT_BANDWIDTH_OP; conn->bandwidth = DEFAULT_BANDWIDTH_OP;
} }
...@@ -615,7 +610,7 @@ int connection_handle_write(connection_t *conn) { ...@@ -615,7 +610,7 @@ int connection_handle_write(connection_t *conn) {
return 0; return 0;
} }
int connection_write_to_buf(char *string, int len, connection_t *conn) { int connection_write_to_buf(const char *string, int len, connection_t *conn) {
if(!len) if(!len)
return 0; return 0;
......
...@@ -73,6 +73,18 @@ int connection_or_finished_flushing(connection_t *conn) { ...@@ -73,6 +73,18 @@ int connection_or_finished_flushing(connection_t *conn) {
/*********************/ /*********************/
void connection_or_init_conn_from_router(connection_t *conn, routerinfo_t *router) {
conn->addr = router->addr;
conn->port = router->or_port;
conn->bandwidth = router->bandwidth;